質問内容
質問を評価する
(0ポイント)
|
皆さんはmapの要素(key,value)を取得する際にどのようなコードを書いていますか?
参考までに教えてください。
ちなみに私は以下のように書いております。 import java.util.*; public class Main {
public static void main(String... args) {
Map<Integer, String> map = new HashMap<Integer, String>(); map.put(new Integer("1"), "apple"); map.put(new Integer("2"), "banana"); map.put(new Integer("3"), "orange"); for(Integer key : map.keySet()){ System.out.format("%d : %s \r\n", key,map.get(key)); }
} }
|