Im trying to understand how class generics work and this bit just doesnt make sense to me.
So for instance if I have the following classes:
class A&l
When you declare
A extends A> a1 = new A();
the compiler knows only that a1
's type parameter is A
or some subclass thereof--it doesn't know which one.
If you change it to A a1
, then it will know that an instance of A
is a legal argument. The same applies for a2
.
On a related note, the line
class B extends A
uses a raw type. You should instead say Class B extends A
or Class B
.