java map안에 map 찾기

25gStroy·2022년 8월 26일
0

JAVA

목록 보기
12/18

map안에 map 찾기

Map map = new HashMap();
Map map2 = new HashMap();map2.put("test", "123");
map2.put("test2", "hello");
map.put("resultMap", map2);

..map.get("resultMap")이런식으로하면 {test=123, test2=hello}이렇게 꺼내지긴하겠지만그안에있는 test나 test2를 꺼낼려면 어떻게 할까?

String o = ((HashMap<?, ?>) result.get(arg)).get("test").toString();

즉 맵안에 맵이 있으니 꺼낼때도 맵을 한번 감싸서 꺼내면 되는 것 이였습니다..

profile
애기 개발자

0개의 댓글