【发布时间】:2014-02-06 11:10:50
【问题描述】:
我已经尝试过这篇文章: Java, Simplified check if int array contains int
并尝试过这个
int[] temp = {3,9,15,21,27,33,39};
HashSet<Integer> otherBy3 = new HashSet<Integer>(Arrays.asList(temp));
根据我在上述链接上看到的指示我这样做的帖子:
HashSet<Integer> set= new HashSet<Integer>(Arrays.asList(intArray));
set.contains(intValue)
但我不断收到此错误
cannot find symbol
symbol : constructor HashSet(java.util.List<int[]>)
location: class java.util.HashSet<java.lang.Integer> HashSet<Integer> otherBy3 = new HashSet<Integer>(Arrays.asList(temp));
任何帮助将不胜感激
【问题讨论】:
-
该链接上的第一个答案指出当
int[]到Arrays.asList时会发生什么(以及为什么它没有按照您的意愿行事)...
标签: java arrays list hashmap instantiation