Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add value into List<Map<String, Object>>?

Tags:

java

arraylist

I'm trying to add a value to an ArrayList.

Here is the code I wrote:

List<Map<String, Object>> list = new ArrayList<>();
list.put(1,"foo", (Object)"bar");

But, this does not work. Anybody have an idea?

like image 661
Rohan Kishibe Avatar asked Aug 10 '16 14:08

Rohan Kishibe


1 Answers

List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("foo", "bar");
list.add(map);
like image 174
shure Avatar answered Sep 23 '22 14:09

shure