2012-03-20 9 views

答えて

4

あなたは、おそらくのようなものを意味する:あなたがマップ内の新しいインスタンスを作成することはできません

Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>(); 
List<Long> list = new ArrayList<Long>(); 
map.put(5, list); 
+0

正確:Dありがとう;) – Mehdi

1

を。あなたはその型の仕様を作成したいだけです。

new HashMap<Integer, List<Long>>(); 

マップの各エントリは、リストの実際のインスタンスを指し示すことができます。どのタイプのリストでも可能です。

map.put(1, new LinkedList<Long>()); 
map.put(2, new ArrayList<Long>()); 
map.put(3, new Vector<Long>()); 
1

Map map = new Hashmap<Integer,List<Long>>;

map.put(1,new ArrayList<Long>());

関連する問題