Java Programming - unchecked conversion

Here is my code:

public Map<String, Map> getStructureMap (String filename)

{

return elementMap.get(filename);

}

I keep getting an unchecked conversion warning. I tried casting the return but then I get an unchecked casting warning. Any body have any ideas?

I should mention elementMap is also of type Map<String, Map>

Thanks.

Message was edited by:

CSAngel

[631 byte] By [CSAngela] at [2007-11-26 23:24:16]
# 1
Have a look here, hope you would get your answer http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#What%20is%20an%20unchecked%20warning?
jayantkdasa at 2007-7-10 14:30:46 > top of Java-index,Java Essentials,Java Programming...
# 2

I should mention elementMap is also of type Map<String, Map>

For your code to make sense and compile without warnings, then, elementMap should be of typeMap<String, Map<String, Map>>(Ignore the extraneous greater-than which the forum put in there.)

DrClapa at 2007-7-10 14:30:46 > top of Java-index,Java Essentials,Java Programming...
# 3

I should mention elementMap is also of type

Map<String, Map>

For your code to make sense and compile without

warnings, then, elementMap should be of

typeMap<String, Map<String, Map>>(Ignore

the extraneous greater-than which the forum put in

there.)

Actually, I think it needs to be:

Map<String, Map<String, String>>

**** - that still doesn't work.

null

CSAngela at 2007-7-10 14:30:46 > top of Java-index,Java Essentials,Java Programming...
# 4

static Map<String, Map<String,Map>> elementMap; // element map need to be Map<String, Map<String,Map>>

public static void main(String[] args) {

elementMap = new HashMap<String,Map<String, Map>>();

elementMap.put("Test",new HashMap<String, Map>());

Map result = getMap("Test");

System.out.println(result.toString());

}

private static Map<String,Map> getMap(String key) //<get method need to return a Map<String, Map>

{

return elementMap.get(key);

}

Edit: As Dr. Clap already said in an earlier post.

~Tim

SomeoneElsea at 2007-7-10 14:30:46 > top of Java-index,Java Essentials,Java Programming...
# 5
Got it. Thanks.
CSAngela at 2007-7-10 14:30:46 > top of Java-index,Java Essentials,Java Programming...