public class TestArray4 {
public static void main(String[] args) {
int[] arr = new int[] {12, 43, 9, 0, -65, -99, 100, 9};
//求最大值
int max = arr[0];//假设第0个元素是最大值
for(int i = 1; i < arr.length; i++) {
if(max < arr[i]) {
max = arr[i]; } }
System.out.println(max);
//求最小值
int min = arr[0];//假设第0个元素是最小值
for(int i = 1; i < arr.length; i++) {
if(min > arr[i]) { min = arr[i]; } }
System.out.println(min);