If I use:
HashMap<String, Integer> test = new HashMap<String, Integer>();
Or I use:
HashMap test = new HashMap();
Is there any difference in further methods that I can apply to the test object. e.g. test.put (), test.get (), etc., if they are initialized differently.
Also, if I put something in a test object, for example:
test.put("One", new Integer(5));
test.put("Two", new Integer(4));
test.put("Three", new Integer(3));
and display it as:
Set set = tokens.entrySet ();
Iterator ik = test.iterator ();
while(ik.hasNext()){
Map.Entry me = (Map.Entry)ik.next();
System.out.println(me.getKey() + " : " + me.getValue() );
The result is not sorted, restul:
Three: 3 One: 5 Two: 1
What rule does he follow? Is this normal output behavior randomly displayed?
Mavin source
share