aspose file tools*
The moose likes Beginning Java and the fly likes Can I have a list in tree map? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can I have a list in tree map?" Watch "Can I have a list in tree map?" New topic
Author

Can I have a list in tree map?

Anthony Alexander
Greenhorn

Joined: Feb 16, 2006
Posts: 15
At the moment I have a Tree Map consisting of a String and Integer,

TreeMap<String, Integer> frequencyData = new TreeMap<String, Integer>( );


The problem now is that I need to hold more than one integer for each string.
Is it possible to have:

TreeMap<String, List>

?
Anthony Alexander
Greenhorn

Joined: Feb 16, 2006
Posts: 15
It seems to be possible but how do I add to the list?

Before I could do:

frequencyData.put(word,x);
(when it was string,integer)

but how do I add to the list?
Anthony Alexander
Greenhorn

Joined: Feb 16, 2006
Posts: 15
List DocRef;
frequencyData.put(word,DocRef.add(x));


???
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Yes you can have a tree map with a list


Garrett


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
 
 
subject: Can I have a list in tree map?