Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Travel {
- // Catches exception
- public static void A() {
- System.out.println("Start of A");
- try {
- B();
- } catch (Exception e) {
- System.out.println("Caught in A : " + e.getMessage());
- }
- System.out.println("End of A");
- }
- // Passes exception to caller
- public static void B() throws Exception {
- System.out.println("Start of B");
- C();
- System.out.println("End of B");
- }
- // Throws exception
- public static void C() throws Exception {
- System.out.println("Throw Exception");
- throw new Exception("Exception from C");
- }
- public static void main(String[] args) {
- A();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement