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
1public class Test {
2
3 public static void main(String args[]) {
4 System.out.println(Math.max(12.123, 12.456));
5 System.out.println(Math.max(23.12, 23.0));
6 }
7}
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