Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I have a list in tree map?

 
Anthony Alexander
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
List DocRef;
frequencyData.put(word,DocRef.add(x));


???
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can have a tree map with a list


Garrett
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic