I have the following code:
public Map<String,?> createItem(String title, String caption) {
Map<String,String> item = new HashMap<String,String>();
item.put(ITEM_TITLE, title);
item.put(ITEM_CAPTION, caption);
(***) item.put(ITEM_NUM, NUM);
in line (*) i have error what i need to do to add the integer
This would be a bad solution and takes away Generics. Would not recommend this but you can get a clear understanding of how all classes(String,Number) extend the Object class. Prior to Java 5 i.e before Generics, Map was something like Map
When using get(key), a cast will be required.