• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how do I fix compiler warning: unchecked conversion

 
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!
 
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should wait and let Katrina answer this one
https://coderanch.com/t/5203/Cattle-Drive/Gahhhr-stuck-Generics-OOP
 
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.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic