Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1.  
  2. public class Travel {
  3.  
  4. // Catches exception
  5. public static void A() {
  6. System.out.println("Start of A");
  7. try {
  8. B();
  9. } catch (Exception e) {
  10. System.out.println("Caught in A : " + e.getMessage());
  11. }
  12. System.out.println("End of A");
  13. }
  14.  
  15. // Passes exception to caller
  16. public static void B() throws Exception {
  17. System.out.println("Start of B");
  18. C();
  19. System.out.println("End of B");
  20. }
  21.  
  22. // Throws exception
  23. public static void C() throws Exception {
  24. System.out.println("Throw Exception");
  25. throw new Exception("Exception from C");
  26. }
  27.  
  28. public static void main(String[] args) {
  29. A();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement