Timeline for Java inheritance and generics [closed]
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 8, 2017 at 12:27 | comment | added | Michael Lang |
Your idea is buggy because you could create classes ChildFoo extends RootFoo<Child2Foo> and Child2Foo extends RootFoo<ChildFoo>. Then the call of Child2Foo foo = new ChildFoo().getThis();would compile but throw a ClassCastException at runtime.
|
|
| Sep 7, 2017 at 11:38 | history | closed |
Antot t3chb0t Graipher Heslacher Toby Speight |
Not suitable for this site | |
| Sep 7, 2017 at 8:49 | answer | added | Antot | timeline score: 3 | |
| Sep 7, 2017 at 8:48 | review | Close votes | |||
| Sep 7, 2017 at 11:38 | |||||
| Sep 7, 2017 at 8:28 | comment | added | regisik | @TimothyTruckle I will pass it into generics ex. public class FooImpl<FooImpl> {} | |
| Sep 7, 2017 at 8:26 | history | edited | regisik | CC BY-SA 3.0 |
deleted 9 characters in body
|
| Sep 7, 2017 at 8:23 | comment | added | Timothy Truckle |
The more interesting question is: why does the calling code has to know which Subclass of RootFoo will be returned? Why is'nt RootFoo getThis() enough?
|
|
| Sep 7, 2017 at 8:12 | review | First posts | |||
| Sep 7, 2017 at 8:14 | |||||
| Sep 7, 2017 at 8:06 | history | asked | regisik | CC BY-SA 3.0 |