Hi
supposing I have the following code:
public class TestwildCards{
public static void main(String arg[]){
List<Integer> mylist=new ArrayList<Integer>();
Bar bar=new Bar();
bar.doInsert(mylist);
}
}
class Bar{
void doInsert(List<Object> list){
list.add(new Dog());
}
}
Will this compile or not ???
Sincd Polymorphism applies to base type only and not to the parameterized type. Here neither the base type nor the parameterized type changes
Will the Dog object be added into the Integer list???
Also what is the difference does it make between List<?> and List<object> ???
Thanks,
Guru
supposing I have the following code:
public class TestwildCards{
public static void main(String arg[]){
List<Integer> mylist=new ArrayList<Integer>();
Bar bar=new Bar();
bar.doInsert(mylist);
}
}
class Bar{
void doInsert(List<Object> list){
list.add(new Dog());
}
}
Will this compile or not ???
Sincd Polymorphism applies to base type only and not to the parameterized type. Here neither the base type nor the parameterized type changes
Will the Dog object be added into the Integer list???
Also what is the difference does it make between List<?> and List<object> ???
Thanks,
Guru