Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. public class Main {
  2.  
  3.    
  4.     public static void main(String[] args)
  5.     throws Exception
  6.     {
  7.        
  8.         throw new Exception("Przykałdowy mój komentarz błędu");
  9.  
  10.     }
  11.  
  12.  
  13. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  14.  
  15.  
  16.  
  17. public class Main {
  18.  
  19.    
  20.     public static void main(String[] args)
  21.     //throws Exception
  22.     {
  23.        
  24.         Example example = new Example();
  25.         double wynik = example.f(10,2);
  26.         System.out.println(wynik);
  27.         wynik = example.f(10, 0);
  28.         System.out.println(wynik);
  29.  
  30.     }
  31.  
  32.     public class Example
  33. {
  34.  
  35.     public double f(int liczba1, int liczba2)
  36.     {
  37.         if (liczba2 == 0)
  38.             throw new ArithmeticException("Błąd dzielenia przez 0");
  39.         return liczba1/liczba2;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement