Skip to content

Instantly share code, notes, and snippets.

@BrantRoom3327
Last active June 20, 2018 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrantRoom3327/424d2ab1a6735db49f513f0a5ddb4fdd to your computer and use it in GitHub Desktop.
Save BrantRoom3327/424d2ab1a6735db49f513f0a5ddb4fdd to your computer and use it in GitHub Desktop.
public class Magician {
public Magician(){}
public Magician(String name){
this.name = name;
}
public String getName() {
return name;
}
String name;
}
Magician magician = new Magician("Miracle Max");
Optional<Magician> optMagician = Optional.ofNullable(magician);
if (optMagician.isPresent())
return optMagician.get(); //returns a Miracle Max Magician
else
System.out.println("Miracle Max isn't home.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment