fork download
  1. import java.util.*;
  2.  
  3. class Ideone
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String a = "a";
  8. String b = null;
  9. String c = "b";
  10.  
  11. System.out.println(get(a) + get(b));
  12. System.out.println(get(a) + get(b) + get(c));
  13. System.out.println(get(b));
  14. }
  15.  
  16. public static String get(String string){
  17. return Optional.ofNullable(string).orElse("");
  18. }
  19. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
a
ab