Computer Applications

Write a code segment that finds the largest integer in this two-dimensional array.

int data[][] = new int[5][5];

Java Arrays

7 Likes

Answer

int l = data[0][0];
for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
        if (data[i][j] > l) {
            l = data[i][j];
        }
    }
}
System.out.println("Largest Element = " + l);

Answered By

5 Likes


Related Questions