public class Test {
public static void main(String[] args) {
int[] array = {12, 35, 64, 43, 63};
int max = array[0];
int min = array[0];
for(int i = 0; i < 4; i++){
if(array[i] < array[i + 1]){
max = array[i + 1];
} else if(array[i] > array[i + 1]){
min = array[i + 1];
}
}
System.out.println("max:" + max + ", min:" + min);
}
}
|