的ArrayList我有一个HashMap
像这样:如何将对象的一个HashMap转换成字符串
Hashmap<String, Object> map = new Hashmap<String, Object>();
map.put(1, {id_student:"1;2;3"});
map.put(2, {id_student:"4;5"});
我想要得到的值,并把它放在一个ArrayList
,如:
array = [0] - 1
[1] - 2
[2] - 3
[3] - 4
[4] - 5
我试图做的:
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));
}
但我从上面的代码得到这个结果:[4, 4;1;2;3, 4;5, 4;5;1;2;3]
在android中编译?它不在Java 8中。'map.put'不会采用'{..}'值。你的意思是'map.put(“1”,new String [] {“1”,“2”,“3”});'? – MadConan