This is a code just to know what is wrong and what is right.
public class JavaApplication5 {
public static void main(String[] args) {
List l=new ArrayList<String>();//Line 1
List<Object> x=new ArrayList<String>();//Line 2
}
}
In the above line 1 is working fine but line 2 gives me compilation error. Can you tell me why?
Are not List
and List<Object>
equivalent? Either both should be wrong or both should be correct.