1int[] arr = {2, 3, 4, 5, 6, 7, 8, 9,};
2 int max = arr[0]; // max tanimliyorsun
3 int min = arr[0]; // min tanimliyorsun
4
5 for (int i = 0; i < arr.length; i++) {
6 if (arr[i] > max){
7// array's index are compared with each other,
8// whichever is greater will be assigned to max
9 max = arr[i];
10 }
11 if(arr[i] < min){
12//array's index are compared with each other,
13// whichever is smaller will be assigned to min
14 min = arr[i];
15 }
16 }
17 System.out.println(max); // 9
18 System.out.println(min); // 2
1 int[] arr = {2, 3, 4, 5, 6, 7, 8, 9,};
2 int max = arr[0]; // max tanimliyorsun
3 int min = arr[0]; // min tanimliyorsun
4
5 for (int i = 0; i < arr.length; i++) {
6 if (arr[i] > max){
7// array's index are compared with each other,
8// whichever is greater will be assigned to max
9 max = arr[i];
10 }
11 if(arr[i] < min){
12//array's index are compared with each other,
13// whichever is smaller will be assigned to min
14 min = arr[i];
15 }
16 }
17 System.out.println(max); // 9
18 System.out.println(min); // 2