fork(1) 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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. NavigableMap<String,String> m = new TreeMap(
  13. new Comparator<String>() {
  14. public int compare(String s1, String s2) {
  15. if (s1 == null && s2 == null) return 0;
  16. if (s1 != null && s2 != null) {
  17. return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
  18. }
  19. return s1 == null ? -1 : 1;
  20. }
  21. }
  22. );
  23. m.put("hello", "world");
  24. m.put("foo", "bar");
  25. m.put(null, "good!");
  26. System.out.println(m.get(null));
  27. System.out.println(m.get("hello"));
  28. System.out.println(m.get("foo"));
  29. }
  30. }
Success #stdin #stdout 0.08s 27804KB
stdin
Standard input is empty
stdout
good!
world
bar