Answer to Question #155395 in Java | JSP | JSF for joy

Question #155395

Print the largest number of an array,


1
Expert's answer
2021-01-14T16:26:45-0500
//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);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog