자바 의 Map 집합 에서 value 의 값 을 어떻게 변경 합 니까?
1648 단어 JAVA 집합 클래스 MAP 와 LIST
보답 하 다
|
조회 1038 회
2015-11-28 15:17
2015-11-28 15:23
\#팀 보물 쟁탈 전,어서 와 서 이번 보물 쟁탈 여행 을 시작 하 세 요!\#
최 적 답안
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.HashMap; import java.util.Map; public class Demo { public static void main(String[] args) { Map m = new HashMap(); m.put( 1 , 1 ); print(m); m.put( 1 , 2 ); print(m); } private static void print(Map m) { for (Map.Entry mm : m.entrySet()) System.out.println( "K: " +mm.getKey()+ ",V: " +mm.getValue()); } } // , key, value 。 본 답변 은 질문 자가 추천 합 니 다.