• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do I fix compiler warning: unchecked conversion

 
Daniel Loranz
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I compile my OOP-2 assignment, I get ...

NaturalLanguageMultiply.java:5: warning: [unchecked] unchecked conversion
found : java.util.HashMap
required: java.util.HashMap<java.lang.String,java.lang.Integer>
private static HashMap<String, Integer> numberMap = new HashMap();


with a marker at the "new".

I'm really not sure what is wrong here. At first I thought the compiler did not like that I'm not handling a HashMap exception, but I'm not calling any HashMap constructors or methods that throw exceptions.

Thanks for any help!
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should wait and let Katrina answer this one
http://www.coderanch.com/t/5203/Cattle-Drive/Gahhhr-stuck-Generics-OOP
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deja vu, anyone?

I thought I was going crazy. I didn't even realize that I was supposed to be writing code for 1.4 ... I learned a lot about Generics and autoboxing right after that incident.

It was worth it!
 
Daniel Loranz
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK - got it. Thanks. Reading about items coming out of a Collection especially made it click for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic