Guest User

Untitled

a guest
Nov 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public class Array {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. int [][] arr= { {4,5,6,7},{1,2,3,8}};
  6. int x;
  7.  
  8. for(int a= 0,b= 0;a<= 3 && b<= 3; a++, b++){
  9. try {
  10. x = arr[a][b];
  11. System.out.println("a = "+ a + " b = "+ b +"n"+ x +"nCorrect----------------------");
  12. }catch(ArrayIndexOutOfBoundsException e) {
  13. System.out.println("a = "+ a + " b = "+ b +"nERROR------------------");
  14. }
  15. }
  16.  
  17.  
  18. }
  19.  
  20. a = 0 b = 0
  21. 4
  22. Correct----------------------
  23. a = 1 b = 1
  24. 2
  25. Correct----------------------
  26. a = 2 b = 2
  27. ERROR------------------
  28. a = 3 b = 3
  29. ERROR------------------
Add Comment
Please, Sign In to add comment