aspose file tools*
The moose likes Cattle Drive and the fly likes how do I fix compiler warning: unchecked conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "how do I fix compiler warning: unchecked conversion" Watch "how do I fix compiler warning: unchecked conversion" New topic
Author

how do I fix compiler warning: unchecked conversion

Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
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

Joined: Jul 22, 2000
Posts: 9053
    
  12
I should wait and let Katrina answer this one
http://www.coderanch.com/t/5203/Cattle-Drive/Gahhhr-stuck-Generics-OOP


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1367
    
  18
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

Joined: Jun 17, 2008
Posts: 41
OK - got it. Thanks. Reading about items coming out of a Collection especially made it click for me.
 
Consider Paul's rocket mass heater.
 
subject: how do I fix compiler warning: unchecked conversion