I have a problem, which read N numbers from the command line, and I want to check if all those numbers are the same.
This is my code
class q2 {
public static boolean check(int[] arr) {
for (int i = 0; i < arr.length-1; i++) {
for (int j = 1; j < arr.length; j++) {
if (arr[i]==arr[j]) return false;
}
}
return true;
}
public static void main(String[] args) {
int[] arr = new int[args.length];
boolean result = check(arr);
System.out.println(result);
}
}
but in any case (but no input at all) it return false and I don't know where is the mistake.