Java: create a list of HashMaps
You need to create a new HashMap for every entry, instead of reusing the existing one. This would work:
HashMap mMap = new HashMap();
mMap.put("start",1);
mMap.put("text","yes");
list.add(mMap);
mMap = new HashMap(); // create a new one!
mMap.put("start",2);
mMap.put("text","no");
list.add(mMap);
also, you can remove the list.add(new HashMap());
as that adds an empty map to your list that is never populated.
Yes, hash map from this piece of code
list.add(new HashMap());
is never referenced. So eventually you get a list of 3 items, 2 of which are identical however.
Something which is maybe also worth mention it, is that you should define the type of the elements you use in the List, for the HashMap its not possible because you are mixing Integers and Strings.
And another thing is that you should use the List interface as type, so you are able to change the implementation (ArrayList or whatever) in the future.
Here the corrected code:
Map mMap = new HashMap();
List<Map> list = new ArrayList();