Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HashMap needs unchecked conversion - Generics warning - please help.

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
0
0
GB
This is a generics thing I believe.

I've simplified my class and method for clarity.

But I get the following warning on line 5:
Type safety: The expression of type HashMap needs unchecked conversion to conform to
HashMap<String,Object>


1: public class aClass {
2: private HashMap<String, Object> mapA;

// Other code, populates mapA

3: void doStuff ( String key ) {
4: HashMap<String, Object> mapB = null;
5: mapB = (HashMap) mapA.get(key);
6: }
7: }



Changing line 5 to:
mapB = (HashMap<String, Object>) mapA.get(key);

gives the warning:
Type safety: The cast from Object to HashMap<String,Object> is actually checking against the
erased type HashMap


Any ideas how to get rid of this warning without suppressing the warning?

Thanks, Martin.
 
This is not a J2EE issue - please post in the standard java forum269 .

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top