This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Hashtable order
- From: "Santosh Cheler" <csk4you at hotmail dot com>
- To: <java at gcc dot gnu dot org>
- Date: Tue, 25 Dec 2001 14:48:50 +0530
- Subject: Hashtable order
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