• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Hash Table Output  RSS feed

 
R Karthick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi My Has table is printing outpus like this
Key : aaa Value : 123
Key : bbb Value : 111
Key : aaa Value : 222

But i want my output like

Key : aaa Value : 123,222
Key : bbb Value : 111

Can anyone please help me?

This is my coding



This is my another coding to do the same. It is also printing the same.



Thanks in Advance..
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what I understand, the table has as its value the arraylist. If that's true, then replace the last bit of your while loop with -



Code not tested, so you might want to tweak it.
 
R Karthick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No man,It is not working :-( i dont know how to solve it. I used a syout to print hte value of "str" like this

String str = (String) names.nextElement();
System.out.println(str);

but nothing is printed. I need help.

Thanks in Advance..
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kinds of objects are you using as keys and values in your Hashtable or HashMap? What is ListObj and what kind of object does ListObj.getKey() return?

Does the class that ListObj.getKey() returns properly implement hashCode() and equals(), which is necessary if you want to use it as a key in a map?
[ October 03, 2008: Message edited by: Jesper Young ]
 
R Karthick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ListObj has only getter and setter.
Now i'm using Hast table only
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!