Guest User

Untitled

a guest
Oct 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public class Handler {
  2.  
  3. Mas mas = new Mas();
  4.  
  5. public void doSmthArray() {
  6. int sum = 0;
  7. if (mas.getMassiv().length > 4) throw new MyArraySizeException();
  8. for (int i = 0; i < mas.getMassiv().length; i++) {
  9. for (int j = 0; j < mas.getMassiv()[i].length; j++) {
  10. try {
  11. sum = sum + Integer.parseInt(mas.getMassiv()[i][j]);
  12. } catch (NumberFormatException e) {
  13. System.out.println();
  14. throw new MyArrayDataException();
  15. }
  16. }
  17. }
  18. }
  19. }
  20.  
  21. public class MainClass {
  22. public static void main(String[] args) {
  23. Handler handler = new Handler();
  24. try {
  25. handler.doSmthArray();
  26. }catch (MyArraySizeException e){
  27. System.out.println("превышен допустимый размер массива");
  28. }catch (MyArrayDataException exc){
  29.  
  30. }
  31. }
  32. }
  33.  
  34. Console.log('i = ' + i + ' j = ' + j);
Add Comment
Please, Sign In to add comment