Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Array {
- public static void main(String[] args) {
- int [][] arr= { {4,5,6,7},{1,2,3,8}};
- int x;
- for(int a= 0,b= 0;a<= 3 && b<= 3; a++, b++){
- try {
- x = arr[a][b];
- System.out.println("a = "+ a + " b = "+ b +"n"+ x +"nCorrect----------------------");
- }catch(ArrayIndexOutOfBoundsException e) {
- System.out.println("a = "+ a + " b = "+ b +"nERROR------------------");
- }
- }
- }
- a = 0 b = 0
- 4
- Correct----------------------
- a = 1 b = 1
- 2
- Correct----------------------
- a = 2 b = 2
- ERROR------------------
- a = 3 b = 3
- ERROR------------------
Add Comment
Please, Sign In to add comment