As title says im getting an index out of bounds exception error at runtime.
Here is the code.
By the way the output of the program should be 10,15,19,12,16,20,13,17,21,14,18,22.
Here is the code.
public class Assign7
{
public static void main(String[] args)
{
int [][] intar = { {10, 12, 13, 14 },
{15, 16, 17, 18 },
{19, 20, 21, 22 } };
System.out.println("Here are the values in the array.");
showArray(intar);
}
private static void showArray(int[][] intar)
{
for (int row = 0; row<3; row++)
{
for (int col = 0; col<4; col++)
System.out.print(intar[col][row]);
}
}
}
By the way the output of the program should be 10,15,19,12,16,20,13,17,21,14,18,22.