标签:str else color sys name span 输出 null tran
Optional< String > firstName = Optional.of( "Tom" );
System.out.println( "First Name is set? " + firstName.isPresent() );
System.out.println( "First Name: " + firstName.orElseGet( () -> "[none]" ) );
System.out.println( firstName.map( s -> "Hey " + s + "!" ).orElse( "Hey Stranger!" ) );
System.out.println();
这个例子的输出是:
First Name is set? true
First Name: Tom
Hey Tom!
标签:str else color sys name span 输出 null tran
原文地址:http://www.cnblogs.com/caiji-blog/p/7435824.html