Java & Spring & SpringBoot
Java Map 모든 key, value 가져오기
Grand_J
2023. 7. 13. 13:58
반응형
Java Map 모든 key, value 가져오기
Map<String, Object> map = new HashMap<>();
map.put("test1", 1);
map.put("test2", 2);
map.put("test3", 3);
// for문
for (Map.Entry<String, Object> e : map.entrySet()) {
System.out.println(String.format("Key ::: %s, Value ::: %s", e.getKey(), e.getValue()));
}
// stream
map
.entrySet()
.stream()
.forEach(e -> System.out.println(String.format("Key ::: %s, Value ::: %s", e.getKey(), e.getValue())));
끗@#%@#$!@$!@$!#%$@%$^%@$#%!#%$!#
반응형