Usually, it is an error to pass a value of a supertype where a value of its subtype is expected.
EDIT : Take an example(though its a very weird one)
interface Testing{
void printValue(TestClient cl);
}
class TestClient implements Testing{
private String content;
public TestClient(String content){
this.content = content;
}
@Override
public void printValue(TestClient cl) {
// TODO Auto-generated method stub
System.out.println((cl.content!=null ?cl.content :"Hello World"));
}
}
public class Test{
public static void main(String args[]) {
Testing t = new TestClient("Hi Friends");
Testing t1 = new TestClient("Hi Enemies");
t1.printValue(t); // generates error (The method printValue(TestClient) in the type Testing is not applicable for the arguments (Testing)
}
}
Here , t1.printValue(t)
method generates the error The method printValue(TestClient) in the type Testing is not applicable for the arguments (Testing)
But in Generics ,Every parameterized type is a subtype of the corresponding raw type, so a value of the parameterized type can be passed where a raw type is expected.
So, why does Java permit a value of a raw type to be passed where a parameterized type is expected— however, it flags this circumstance by generating an unchecked conversion warning.