Results 1 to 5 of 5
Thread: Treemaps
- 08-25-2010, 08:11 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 11
- Rep Power
- 0
- 08-25-2010, 09:00 PM #2
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
The object "TreeMap" expects two integers as parameters. I don't have experience with TreeMap's, but with HashMaps, when you insert data into them, you place two integers to abide by the parametrized object.
- 08-26-2010, 09:32 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Nonsense.
Or at least a misunderstanding of what a Map is.
Maps (all Maps) map a Key to a Value. What that code above is doing is declaring treeMap as of type TreeMap<Integer, Integer>, the first being the class of the key and the second being the class of the value. It is also initialising it (the stuff on the right hand side).
The <..> stuff is all to do with generics.
- 08-26-2010, 11:00 AM #4
The code above does nothing but give you a compilation error because it is a typo.
should be:Java Code:TreeMap(Integer,Integer> treeMap = new TreeMap<Integer,Integer>();
Java Code:TreeMap<Integer,Integer> treeMap = new TreeMap<Integer,Integer>();
"Experience is what you get when you don't get what you want" (Dan Stanford)
"Rise and rise again until lambs become lions" (Robin Hood)
- 08-26-2010, 11:04 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
TreeMaps
By DavidG24 in forum New To JavaReplies: 4Last Post: 05-05-2009, 05:47 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks