이상한 결과가 나왔고 설명 할 수 없습니다. 나는 sysos에서잘못된 목록을 가져 오는 이유는 무엇입니까?
> {Level=1 - Normal, Name=IT/Java}
> {Level=2 - Medium, Name=IT/Ruby}
> [{Level=2 - Medium, Name=IT/Ruby}, {Level=2 - Medium, Name=IT/Ruby}]
을받을 이유 , 당신은 아이디어가 있습니까? 실제로
> {Level=1 - Normal, Name=IT/Java}
> {Level=2 - Medium, Name=IT/Ruby}
> [{Level=1 - Normal, Name=IT/Java}, {Level=2 - Medium, Name=IT/Ruby}]
해야 할 때 여기 내 코드입니다.
public List<Map<String, Object>> getMapsforTables() {
levelList = this.getSkilllevel();
description = this.getSkillnames();
Map<String, Object> rm = new HashMap<String, Object>();
List<Map<String, Object>> l = new LinkedList<Map<String, Object>>();
for(int i=0; i < levelList.size(); i++){
rm.clear();
rm.put("Name", description.get(i));
rm.put("Level", levelList.get(i));
System.out.println(rm);
l.add(rm);
}
System.out.println(l);
return l;
}
오브젝트와 참조가 무엇인지 배우십시오. 오브젝트를 다른 오브젝트에 배치하는 동안 오브젝트를 계속 변경하고 이후에 오브젝트가 변경된다는 점을 알아 두십시오. – Smutje