fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. private static boolean test = true;
  11.  
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. // your code goes here
  15. }
  16.  
  17. public static List<String> foo1() {
  18. List<String> retval = bar();
  19. if (retval == null)
  20. return Collections.emptyList();
  21. else
  22. return retval;
  23. }
  24.  
  25. public static List<String> foo2() {
  26. List<String> retval = bar();
  27. return retval == null ? Collections.<String>emptyList() : retval;
  28. }
  29.  
  30. public static List<String> bar() {
  31. test = test ^ true;
  32. if (test) {
  33. return new ArrayList<String>();
  34. } else {
  35. return null;
  36. }
  37. }
  38. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
Standard output is empty