Map<String, Integer>[][] it=new HashMap<String, Integer>[10][20];为什么这样定义不行呢?

解决方案 »

  1.   

    Map 底层实现时候就是一个数组,不需要再定义成数组了,LZ可以看看API
    定义成Map <String, Integer> it=new HashMap <String, Integer>();就好了
      

  2.   

    你这样写是可以的,Map <String, Integer>[][] it = new HashMap[10][20];但是会有unchecked的危险。Java中是无法创建泛型数组的。
      

  3.   

    ArrayList< HashMap<String, Integer>[][] > it = new ArrayList< HashMap<String, Integer>[][] > it(10);就是想让it中的每个变量都定义为HashMap<String, Integer>[10][20]
    不知道这样可以实现否?
      

  4.   

    ArrayList < HashMap <String, Integer>[][] > it = new ArrayList < HashMap <String, Integer>[][] > it(10); 就是想让it中的每个变量都定义为HashMap <String, Integer>[10][20] 
    不知道这样可以实现否?