Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Driver {
- // Complete a driver to test the methods of the Maps
- public static void main(String [] args)
- {
- HashMap<Integer, String> newMap = new HashMap();
- newMap.put( 0,"Alfalfa");
- newMap.put(1, "Bologna");
- newMap.put(2, "Canuck");
- newMap.put(13,"Jabberwocky");
- newMap.put(3, "Digress");
- newMap.put(4, "Egress");
- newMap.put(5, "Ferdinand");
- /*for(int i = 0; i < newMap.size(); i++)
- {
- System.out.println(newMap.get(i));
- }*/
- for(String s: newMap.values())
- {
- System.out.println(s);
- }
- HashMap<Integer, String> newMap2 = new HashMap();
- newMap2.put(0, "Bill");
- newMap2.put(5, "Rawr");
- newMap2.put(6, "Aardvark");
- newMap.putAll(newMap2);
- for(int i = 0; i <newMap2.size(); i++)
- {
- System.out.println(newMap2.get(i));
- }
- System.out.println(newMap2.remove(2));
- newMap.clear();
- //System.out.println(newMap.get(0));
- System.out.println(newMap2.containsValue("Bobby"));
- for(String s: newMap2.values())
- {
- System.out.println(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment