Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package wyjatki;
  2.  
  3. public class Wyjatki {
  4.  
  5. void wypiszDlugosc(int liczba) throws NullPointerException {
  6. //System.out.println(s);
  7. }
  8.  
  9.  
  10. public static void main(String[] args) throws Exception {
  11. int liczba;
  12. Wyjatki z = new Wyjatki();
  13.  
  14.  
  15. try {
  16. z.liczba(-10);
  17. }
  18. catch (Exception e) {
  19. if (liczba < 0){ throw new NowyWyjatek("NowyWyjatek test");
  20. }else System.out.println(s);
  21. throw new NowyWyjatek("Nowy Wyjątek");
  22.  
  23. }
  24. }
  25. }
  26.  
  27.  
  28. /////////////////////////////////////////////////////////////////////////////////
  29.  
  30.  
  31. package wyjatki;
  32.  
  33. class NowyWyjatek extends Exception {
  34. public NowyWyjatek() {
  35. super();
  36. }
  37.  
  38. public NowyWyjatek(String message) {
  39. super(message);
  40. }
  41.  
  42. public NowyWyjatek(Throwable cause) {
  43.  
  44. super(cause);
  45. }
  46.  
  47. public NowyWyjatek(String message, Throwable cause) {
  48. super(message, cause);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement