java Map数组定义出现的警告
publicstaticMap<String,String>[]maps=null;publicstaticvoidnewDBParameter(intlength){m...
public static Map<String, String> [] maps = null ;
public static void newDBParameter(int length){
maps = new HashMap[length] ;//黄色警告
}
maps = new HashMap[length] 这句该怎么写才消除警告
new HashMap<String,String>[length];//报错 展开
public static void newDBParameter(int length){
maps = new HashMap[length] ;//黄色警告
}
maps = new HashMap[length] 这句该怎么写才消除警告
new HashMap<String,String>[length];//报错 展开
展开全部
应该是maps = new HashMap(length)吧,数组采用[]定义。
看看hashmap构造函数:
Constructor and Description
HashMap()
Constructs an empty HashMap with the default initial
capacity (16) and the default load factor (0.75).
HashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial
capacity and the default load factor (0.75).
HashMap(int initialCapacity,
float loadFactor)
Constructs an empty HashMap with the specified initial
capacity and load factor.
HashMap(Map<?
extends K,? extends V> m)
Constructs a new HashMap with the same mappings as the
specified Map.
看看hashmap构造函数:
Constructor and Description
HashMap()
Constructs an empty HashMap with the default initial
capacity (16) and the default load factor (0.75).
HashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial
capacity and the default load factor (0.75).
HashMap(int initialCapacity,
float loadFactor)
Constructs an empty HashMap with the specified initial
capacity and load factor.
HashMap(Map<?
extends K,? extends V> m)
Constructs a new HashMap with the same mappings as the
specified Map.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询