Hashtable order
Santosh Cheler
csk4you@hotmail.com
Tue Dec 25 01:14:00 GMT 2001
hi gnu-java folks
I have a question about the hashtable implementation,
in jdk1.2, jdk1.3 and gnu-java(libgcj).
the question is, what is the order of output of the
following piece of code:
-----
Hashtable h = new Hashtable();
h.put ("a", new Integer(1));
h.put ("b", new Integer(2));
h.put ("c", new Integer(3));
for (Enumeration e = h.keys(); e.hasMoreElements();)
Object o = e.nextElement();
System.out.println(o.hashcode() + ". ", o + ", "+h.get(o));
}
-----
So for the keys a b c, jdk1.2 prints c b a
and jdk1.3 prints b a c. and gcj also prints
b a c. The hashCodes are same with all the three
versions.
I had a look at the source of Hashtable.java in jdk1.2
and jdk1.3, and both were equivalent. So where is the
difference? I know, order is not supported by java1.2
spec, but does somebody know the matter?
I tried using gdb(with gcj), but I am not able to step
into the java code. Any help here? any docs on debugging
java source with gdb?
TIA
csk
More information about the Java
mailing list