[quote:17qzqrfu]Hashtable<String, String> table2=new Hashtable <String, String>();
table2.put("PIN1", "12345");
table2.put("PIN1", "56798");
table2.put("PIN1", "67895");
table2.put("PIN1", "01234");[/quote:17qzqrfu]
you have put the same key.
so, "12345" is replaced by "56798" and so on.
so thats why the output is {PIN1=01234}
use this
[quote:17qzqrfu]Hashtable<String, String> table2=new Hashtable <String, String>();
table2.put("PIN1", "12345");
table2.put("PIN2", "56798");
table2.put("PIN3", "67895");
table2.put("PIN4", "01234");[/quote:17qzqrfu]
[quote="qtpselenium.supp0rt@gmail.com":akywb31v][quote:akywb31v]Hashtable<String, String> table2=new Hashtable <String, String>();
table2.put("PIN1", "12345");
table2.put("PIN1", "56798");
table2.put("PIN1", "67895");
table2.put("PIN1", "01234");[/quote:akywb31v]
you have put the same key.
so, "12345" is replaced by "56798" and so on.
so thats why the output is {PIN1=01234}
use this
[quote:akywb31v]Hashtable<String, String> table2=new Hashtable <String, String>();
table2.put("PIN1", "12345");
table2.put("PIN2", "56798");
table2.put("PIN3", "67895");
table2.put("PIN4", "01234");[/quote:akywb31v][/quote:akywb31v]
Thank you. Now, after chaning the key to PIN1,PIN2,PIN3,PIN4 - my output is -
{City3=Delhi, City2=Pune, City1=Bangalore}
{PIN4=01234, PIN3=67895, PIN2=56798, PIN1=12345}
Where as in your example, I don't see the keys r getting displayed. Only the value is getting displayed. Also, It is only one value is getting displayed for the same syntax what I have used above. Please help me in understanding this. Thank you.
[quote:1e4e76qs]Where as in your example, I don't see the keys r getting displayed. Only the value is getting displayed. Also, It is only one value is getting displayed for the same syntax what I have used above. Please help me in understanding this. Thank you.[/quote:1e4e76qs]
the actual usage of hash tables is that you call value by key.
but if you want the keys for some reason this is it.
http://www.tutorialspoint.com/java/util/hashmap_keyset.htm