JAVA-SE-Tutorial-codeswithpankaj icon indicating copy to clipboard operation
JAVA-SE-Tutorial-codeswithpankaj copied to clipboard

largest element in an array

Open krishna-1284 opened this issue 1 year ago • 0 comments
trafficstars

public class Main {

public static void main(String[] args) {
    int[] numbers = {10, 25, 50, 5, 35, 75, 20};

    int max = numbers[0];
    for (int i = 1; i < numbers.length; i++) {

        if (numbers[i] > max) {
            max = numbers[i];
        }
    }
    System.out.println("The largest element in the array is: " + max);
}

}

krishna-1284 avatar Aug 09 '24 17:08 krishna-1284