aspose file tools*
The moose likes Beginning Java and the fly likes hashtable of arraylists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "hashtable of arraylists" Watch "hashtable of arraylists" New topic
Author

hashtable of arraylists

phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have a arraylist appdetails.

This arraylist contains the beans Bean.getApp1(),Bean.getappr() and Bean.getComm()
I want to add to hashtable htappdeatils. exAppBean bean1 = new exAppBean();
AppBean Bean = new AppBean();

I have a key for hashtable htappDetails (String)Bean.getMon()+(String)Bean.getyear()

for(int j=0; j<appdetails.size();j++) {


Bean = (bean1)appdetails.get(j);
htappDeatils.put((String)Bean.getMon()+(String)Bean.getyear(),Bean.getApp1())
}

How can I add other beans Bean.getappr() and Bean.getComm() to the same hashtable htappdetails for the same key?
[ September 21, 2005: Message edited by: Ernest Friedman-Hill ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

These aren't advanced questions, so you shouldn't be posting them in Java in General(Advanced). I'm going to move this one to Java in General(Beginner) for you.

Secondly, you need to use more descriptive subject lines if you want anyone to read your posts -- this is JavaRanch, so a subject line of "Java" isn't very explanatory. I'm going to rename this post to "hashtable of arraylists" when I move it.

Finally, as to your question, I'm not sure where your problem lies. Is your code not compiling because of "incompatible type" errors? Are you unclear on how to find the arraylist associated with a particular key? Can you please clarify your question somewhat?


[Jess in Action][AskingGoodQuestions]
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I want to know, how to add other beans like bean.getappr() and bean.getComm() to the same hashtable for the same key?
Julien Grenier
Ranch Hand

Joined: Sep 01, 2005
Posts: 41
well you can't directly. you need to put your bean.getappr() and bean.getComm() and bean.getApp1() into a List under the key in the hashmap.
something like this

or more useful could be to put all your bean into the hashmap like this


this way you can get your beans from the Hashmap like this
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have a arraylist appdetails.

This arraylist contains the beans Bean.getApp1(),Bean.getappr() and Bean.getComm()
I want to add to hashtable htappdeatils. exAppBean bean1 = new exAppBean();
AppBean Bean = new AppBean();

I have a key for hashtable htappDetails (String)Bean.getMon()+(String)Bean.getyear()

for(int j=0; j<appdetails.size();j++) {


Bean = (bean1)appdetails.get(j);
htappDeatils.put((String)Bean.getMon()+(String)Bean.getyear(),Bean.getApp1())
}


I have another problem with this. When I try to access Bean.getComm() by using System.out.println(" bean " +Bean .getComm()) outside for loop, I am getting null value. How can I access Bean.getComm() value outside for loop???
System.out.println(" comm
 
 
subject: hashtable of arraylists