Skip to content

largest element in an array #12

Open
@krishna-1284

Description

@krishna-1284

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);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions