I have an ArrayList<int[]>
, and I add an array to it.
ArrayList<int[]> j = new ArrayList<int[]>();
int[] w = {1,2};
j.add(w);
Suppose I want to know if j
contains an array that has {1,2}
in it without using w
, since I will be calling it from another class. So, I create a new array with {1,2}
in it...
int[] t = {1,2};
return j.contains(t);
...but this would return false even though w
was added to the list, and w
contains the exact same array as t
.
Is there a way to use contains such that I can just check to see if one of the elements of the ArrayList
has the array value {1,2}
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…