int[]? a={8,7, 1,6,484,54,8 }; //Define an array
int? sum? =? 0;
For what? (int? Me? :? a)? {
sum+= I; //Sum all elements in the array.
}
system . out . println(" average:"+sum/a . length);
//Maximum method 1
arrays . sort(a); //Arrays are sorted in ascending order.
int? max = a[a . length- 1]; //Get the last number of the array
system . out . println(" Maximum:"+max);
//Maximum Method 2
int? max 1 = 0; //Assume that this number is the maximum.
For what? (int? Me? =? 0; ? Me? & lt? A. length; ? i++)? {
What if? (a[I]& gt; max 1)? {
max 1 = a[I]; //The value of an element in the array is greater than the current maximum. Assign this value to max 1.
}
}
system . out . println(" maximum:"+max 1);
}