for some reason when I try and add an integer array as the parameter of this method when I call it in my main method, it doesn't recognise the parameter as an array or something, I'm not sure why it does this. I call the array like this: has23([2,4]).
public static boolean has23(int[] n) {
Boolean correct = null;
while ((n.length == 2)) {
for (int i : n) {
Arrays.asList(n);
if (Arrays.asList(n).contains(2) || Arrays.asList(n).contains(3)) {
correct = true;
}
else;
correct = false;
}
}
System.out.println(correct);
return correct;
}
Because
has23([2, 4])
is not legal Java syntax. You can do
has23(new int[] { 2, 4 })
instead. Or
int[] arr = { 2, 4 };
has23(arr);
but not
has23({2, 4});