Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- A getThis() {System.out.println("call getThis() from A"); return this;} //(3)
- Object getSuper() {System.out.println("call getSuper() from A"); return null;}
- }
- class B extends A {
- B getThis() {System.out.println("call getThis() from B"); return this;}
- A getSuper() {System.out.println("call getSuper() from B"); return super.getThis();}
- }
- class Tester {
- public static void main (String[] args) {
- Object a = new B().getSuper(); //(1)
- System.out.println(a);
- a = new B().getSuper().getSuper(); //(2)
- System.out.println(a);
- }
- }
- static class A {
- A getThis() {System.out.println("call getThis() from A"); return this;} //(3)
- Object getSuper() {System.out.println("call getSuper() from A"); return null;}
- }
- static class B extends A {
- B getThis() {System.out.println("call getThis() from B"); return this;}
- A getSuper() {System.out.println("call getSuper() from B"); return super.getThis();}
- }
Add Comment
Please, Sign In to add comment