I have a HashMap like so:
Hashmap<String, Object> map = new Hashmap<String, Object>();
map.put(1, {id_student:"1;2;3"});
map.put(2, {id_student:"4;5"});
I want to get the values and put it in an ArrayList like:
array = [0] - 1
[1] - 2
[2] - 3
[3] - 4
[4] - 5
what I tried to do:
private Set<String> checked = new TreeSet<String>();
String idsAlunos = "";
for (Iterator<Map.Entry<String, GPSEscolas>> it = aMap.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, GPSEscolas> entry = it.next();
String id_escola = entry.getKey();
String ids_aluno = entry.getValue().getAlunos();
idsAlunos += ";" + ids_aluno;
checked.add(idsAlunos.substring(1));
}
but I'm getting this result from above code: [4, 4;1;2;3, 4;5, 4;5;1;2;3]
map.putwon't take the{..}values. Do you meanmap.put("1",new String[]{"1","2","3"});?