해시 맵 값을 List에 전달하는 방법 항목의 형식은 String key 및 value입니까?목록에 HashMap 값을 전달하는 방법
페이지 클래스 :
Map<String, String> info = new HashMap<String, String>();
info.put("abc", "123")
나는이 시도 : 나는지도 만든
public List<Entry> entry;
public void setEntry(final List<Entry> entry) {
this.entry = entry;
this.setInfo(entry);
}
public void setInfo(final List<Entry> entryList) {
this.prop = new HashMap<String, String>();
for (Entry objEntry : this.entry) {
this.prop.put(objEntry.getKey(), objEntry.getValue());
}
}
public void setInfo(final List<Entry> entryList)
의 당신의 방법에서
List l = new ArrayList(info.values());
page.setInfo(list); // I am getting class cast exception
을하는 데 도움이됩니다. – chrylis
이것은 원시 타입을 사용하지 않는 이유입니다 ... 만약 당신이 원시 타입을 사용하지 않는다면 컴파일되지 않습니다. – Radiodef
페이지 클래스에서 setInfo 메서드 : for 루프를 개선했습니다. entryList로 this.entry를 바꿉니다. – techGaurdian