Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3.  
  4. public class Exceptions {
  5.  
  6. public void catcher() {
  7. try {
  8. podniesArrayIndexOutOfBoundsException();
  9. podniesFileNotFoundException();
  10. podniesException();
  11. }
  12. catch(ArrayIndexOutOfBoundsException e) {
  13. System.out.println(e);
  14. }
  15. catch(FileNotFoundException e) {
  16. System.out.println(e);
  17. }
  18. catch(Exception e) {
  19. System.out.println(e);
  20. }
  21. }
  22.  
  23. public void podniesArrayIndexOutOfBoundsException() {
  24. throw new ArrayIndexOutOfBoundsException();
  25. }
  26.  
  27. public void podniesFileNotFoundException() throws FileNotFoundException {
  28. throw new FileNotFoundException();
  29. }
  30.  
  31. public void podniesException() throws Exception {
  32. throw new Exception("zła jednostka");
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement