I had this snippet in my code to check if every value of an array was contained in another array (basically for filtering).
This is the snippet
public boolean linearIn(int[] subarray, int[] array) {
for (int i = 0; i < subarray.length; i++) {
if (!Arrays.asList(array).contains(subarray[i])) {
Log.d(TAG, "Array doesn't contain " + subarray[i]);
return false;
}
}
return true;
}
This used to work. I remember because it worked in an app I am working on. What do I mean by it worked? Well actually it could understand when there were or there weren't matches, indeed a filter was applied.
Now it turns out that it just never works. With the Log it outputs that doesn't find 0 even when I know that array contains a 0.
But luckily Android Studio isn't silent about this. This is the warning that gives at the if-statement:
List<int[]>' may not contain objects of type 'Integer' more... (CTRL+F1)
At the time I was inspired by the 3rd answer in this question.
And I was satisfied since it worked on my code, and it's pretty easy to say this since now it couldn't even find one match.
Now I resolved using Integer types (a bit unconfortable since it requires a loop for casting if I must have an int[])
Is it possible that SDK changed in the updates in a way that broke this code snipped?