How Can I create a generic HashMap to insert collections and objects?

Viewed 66062

How Can I instantiate a HashMap to put collections and objects?.

//it's wrong
Map<String,?>params=new HashMap<String,? >
List<Person> lstperson=getPerson();
params.put("person",lstperson);
params.put("doc",objectDoc);
params.put("idSol",new Long(5));
service.method(params);

//method

public void method(Map<String, ?> params);
4 Answers

I cam here for substitute in Kotlin

You can declare in kotlin as :-

val map: Map<String, Any?>
Related