write a java code that print the largest number of an array,
public void findMax(int[] arr) {
int max = Integer.MIN_VALUE;
for (int i = 0; i < arr.length; i++) {
max = Math.max(max, arr[i]);
}
System.out.println("The max number is: " + max);
}
Comments
Leave a comment