waltermilner

Untitled

Dec 30th, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1.     Map<String, String> map= new HashMap<>();
  2.     String value;
  3.     value=map.get(null);
  4.     System.out.println(value); // null - there is no pair with key==null
  5.     map.put(null, "Hello");
  6.     value=map.get(null);
  7.     System.out.println(value); // Hello - now there is a value with key = null
  8.     map=null;
  9.     value=map.get(null); // NPE - do not follow the null pointer!!
Advertisement
Add Comment
Please, Sign In to add comment