Advertisement
jbjares

pegadinha_java

Sep 4th, 2015
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1.     @Test
  2.     public void test() {
  3.         Map<Long,String> map = new HashMap<Long,String>();
  4.         map.put(1L, "a");
  5.         map.put(2L, "b");
  6.         changeMethod(map);
  7.         System.out.println(map.get(2L));
  8.     }
  9.  
  10.     private void changeMethod(Map<Long, String> map) {
  11.         Map<Long,String> otherMap = new HashMap<Long,String>();
  12.         otherMap.put(1L,"c");
  13.         otherMap.put(2L,"d");
  14.         map = otherMap;
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement