Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiler warning for TreeMap

 
M Burke
Ranch Hand
Posts: 399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I do the put() I get a warning in Java 1.5:

TreeMap vo = new TreeMap();

Object[] rc = (Object[]) irc.next();
Integer locOrder = (Integer) rc[0];
MenuItem mI = (MenuItem) rc[1];
vo.put(locOrder, mI);

"Type safety: The method put(Object, Object) belongs to the raw type TreeMap. References to generic type TreeMap<K,V> should be parameterized"

How do I resolve this?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use generics to indicate the type of keys and values, a new feature of Java 1.5.

TreeMap<Integer, MenuItem> vo = new TreeMap<Integer, MenuItem>();
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the declaration toRead up on Generics (a new Java 1.5 feature) to understand this.
 
M Burke
Ranch Hand
Posts: 399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that works. Is there a doc out there that talks about 1.5 changes?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by M Burke:
... Is there a doc out there that talks about 1.5 changes?

J2SE 5.0 in a Nutshell
[ October 06, 2005: Message edited by: marc weber ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by M Burke:
Thanks, that works. Is there a doc out there that talks about 1.5 changes?


Sun's official list
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic