1public static double arrayMax(double[] arr) {
2 double max = Double.NEGATIVE_INFINITY;
3
4 for(double cur: arr)
5 max = Math.max(max, cur);
6
7 return max;
8}
1import java.util.Random;
2
3public class Main {
4
5public static void main(String[] args) {
6 int a[] = new int [100];
7 Random rnd = new Random ();
8
9 for (int i = 0; i< a.length; i++) {
10 a[i] = rnd.nextInt(99-0)+0;
11 System.out.println(a[i]);
12 }
13
14 int max = 0;
15
16 for (int i = 0; i < a.length; i++) {
17 a[i] = max;
18
19
20 for (int j = i+1; j<a.length; j++) {
21 if (a[j] > max) {
22 max = a[j];
23 }
24
25 }
26 }
27
28 System.out.println("Max element: " + max);
29}
30}