Skip to content
Home » Blog » Java Program to Find Largest Element of an Array

Java Program to Find Largest Element of an Array

Largest Element Array

In this Programme, you’ll learn Program to Find Largest Element Array in Java.

To nicely understand this example of to find Largest Element Array, you should have knowledge of  Java Program

Program to Find the largest element in an array in Java

public class Largest {

    public static void main(String[] args) {
        double[] numArray = { 23.4, -34.5, 50.0, 33.5, 55.5, 43.7, 5.7, -66.5 };
        double largest = numArray[0];

        for (double num: numArray) {
            if(largest < num)
                largest = num;
        }

        System.out.format("Largest element = %.2f", largest);
    }
}

After Compiling the above code we get Output

Largest element = 55.50

Ask your questions and clarify your/others doubts on how to find Largest Elements Array by commenting or Posting your Doubt on Forum. Documentation

More Examples

1. Java Program to Convert String to Date
2. Java Program to Get Current Date/TIme
3. Java Program to Convert Milliseconds to Minutes and Seconds