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