Java 8 Optional instead of if

Viewed 16562

I have problem with Optional and I don't know how to handle it.

public void check(String name) {
   if (name != null)
      doSomething(name);
   else 
      doMore();
} 

How to change this if into Optional?

4 Answers
Related