w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Array Index out of Bound Exception while running the program to find largest of an array

You miss a { after the for (i = 0; i < rows; i++) so that the for (int j = 0; j < 5; j++) loop is inside the first one.

Without that, this gives:

for (i = 0; i < rows; i++)
  l = a[i][0];
// End of the for i loop, now i = rows. 
for (int j = 0; j < 5; j++)
  if (l < a[i][j])  // i = rows: bang.
    l = a[i][j];




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.