Please explain me why if I use the raw type A in the method test() , the get() method on my typed list returns an Object and not a B.:
public class test
{
public class B{}
public class C{}
public class A<T extends C>
{
private List<B> aBList;
public List<B> mGetBList()
{
return aBList;
}
}
public test(A pA) // Use of raw type - this is bad, I know!
{
B lB = pA.mGetBList().get(0); // Compile error: Type mismatch:
// cannot convert from Object to test.B
}
}
If I declare
public test(A<?> pA)
the get() method returns a B as expected.