I have a problem with my Hashtable output
Hashtable HashTest = new Hashtable();
HashTest.put("B_1", "A");
HashTest.put("B_3", "B");
HashTest.put("B_5", "C");
HashTest.put("B_7", "D");
HashTest.put("B_9", "E");
HashTest.put("B_11", "F");
HashTest.put("J_1", "G");
HashTest.put("J_3", "H");
HashTest.put("J_5", "I");
HashTest.put("J_7", "J");
HashTest.put("J_9", "K");
Enumeration enum1, enum2;
enum1 = HashTest.keys ();
enum2 = HashTest.elements ();
String CityCode, CityName;
while (enum1.hasMoreElements ())
{
CityCode = (String) enum1.nextElement ();
CityName = (String) enum2.nextElement ();
System.out.println("City Code " + CityCode + " Name " + CityName );
}
The out put looks like this:
City Code B_3 Name B
City Code B_1 Name A
City Code B_11 Name F
City Code J_9 Name K
City Code J_7 Name J
City Code J_5 Name I
City Code J_3 Name H
City Code B_9 Name E
City Code J_1 Name G
City Code B_7 Name D
City Code B_5 Name C
This output is not arranged the way I entered it. nay suggestions?
I do not want to sort the output alphabetically, i just want it to display this way
City Code B_1 City Name A
City Code B_3 City Name B
City Code B_5 City Name C
City Code B_7 City Name D
City Code B_9 City Name E
City Code B_11 City Name F
City Code J_1 City Name G
City Code J_3 City Name H
City Code J_5 City Name I
City Code J_7 City Name J
City Code J_9 City Name K