Forum Stats

  • 3,722,782 Users
  • 2,244,412 Discussions
  • 7,850,085 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Lesson 2 > Section 7 > Page 7 : Transform Optional value ifPresent

From the following snippet of code on Lesson 2 : Section 7 : Page 7

    opt.map(String::trim)      .filter(t -> t.length() > 0)      .ifPresent(this::print);

Can someone help me understand how it's going to work fine even when opt contains null value.

Will there be an optimization on the lambdas (map and filter) to execute only when the variable opt contains value?

Thank you.

Sign In or Register to comment.