HashMap Comments
Comments
-
HI I ran this in eclipse and am getting the same output as here...
HashMap map;
map = new HashMap();map.put("user", "pass");
map.put("username", "password"); map.put("java", "programming"); /* * Printing a HashMap calls the toString method of the AbstractMap class * TODO Write the code to print the HashMap * Output: {username=password, java=programming, user=pass} */ System.out.println(map);
According to your Correct Output, it should print like {username=password, java=programming, user=pass}
but it simply doesn't. -
It looks like it could print the items inside the hashmap in a different order (this is because HashMaps do not preserve the order of the elements). I simplified the problem so the correct solution
does not involve printing a hashmap with more than one item in it. Sorry for the issue and thanks for letting me know!
Jason Runkle
Apr 16, 11:51 PM"The code below demonstrates most of ArrayList's methods (as shown above), but it's missing certain parts."
Just guessing, but I think you meant to say HashMap instead of ArrayList up there...