martindavey
Programmer
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.
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.