Why doesn't my code work, always returns true?
public static void main(String[] args) {
int [] array = {54321};
int [] array2 = {13445};
int []array3 = {12345};
System.out.println(isInOrder(array)); }
public static boolean isInOrder(int [] array){
boolean isTru=true;
for (int i = 0; i < array.length-1; i++) {
if (array[i] > array[i+1]) {
isTru= false;
}
else
isTru=true;
}
return isTru;
}
Posted May 15, 2016, 8:15 PM UTC
04