Adding and removing of dictionaries elements in Java
Forums:
Map<Integer, String> dic = new HashMap<Integer, String>();
dic.put(1, "one");
dic.put(2, "two");
dic.put(3, "tree");
//dic is {1=three, 2=two, 3=tree}
dic.replace(3, "three");
//dic is {1=one, 2=two, 3=three}
dic.remove(3);
//dic is {1=one, 2=two}
dic.clear();
//dic is empty
- Log in to post comments