fork(2) download
  1. import java.util.HashMap;
  2.  
  3. class MapDem {
  4.  
  5. final HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
  6.  
  7. public HashMap<Integer, Integer> getMap() {
  8. return map;
  9. }
  10.  
  11. public void putValue(int key, int value) {
  12. map.put(key, value);
  13. }
  14.  
  15. public static void main(String args[]) {
  16. MapDem demo = new MapDem();
  17.  
  18. demo.putValue(1, 10);
  19. demo.putValue(1, 10);
  20.  
  21. System.out.println(demo.getMap().size());
  22. }
  23. }
Success #stdin #stdout 0.04s 842240KB
stdin
Standard input is empty
stdout
1