Print the largest number of an array,
//Print the largest number of an array,
public class Main {
public static void main(String[] args) {
int[] array = new int[]{1, 2, 3, 4, 5, 6, 7, 8};
int max = Integer.MIN_VALUE;
for (int j : array) {
if (j > max) {
max = j;
}
}
System.out.println("the largest number of an array is " + max);
}
}
Comments
Leave a comment