Created
April 25, 2018 20:55
-
-
Save fhanik/915a9792b619049b380cd81000bdd84b to your computer and use it in GitHub Desktop.
Subclass in super class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String... args) throws Exception { | |
C c1 = new C() | |
.<C>something() | |
.<C>somethingElse() | |
.<C>anotherSet(); | |
C c2 = new C() | |
.<C>anotherSet() | |
.<C>something() | |
.<C>somethingElse(); | |
C c3 = new C() | |
.<C>anotherSet() | |
.<C>something() | |
.<C>somethingElse(); | |
} | |
public static class A { | |
public <T> T something() { | |
return (T)this; | |
} | |
} | |
public static class B extends A { | |
public <T> T somethingElse() { | |
return (T) this; | |
} | |
} | |
public static class C extends B { | |
public <T> T anotherSet() { | |
return (T) this; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment