Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


HashMap needs unchecked conversion - Generics warning - please help.

HashMap needs unchecked conversion - Generics warning - please help.

HashMap needs unchecked conversion - Generics warning - please help.

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

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close