Hi,
What is the difference between :
List<String> x1= new ArrayList<String>();
and
List<String> x1= new ArrayList();
The first one here is a proper type safe ArrayList. There can't be anyything thats not a String in that ArrayList. Here the second one isn't necessarily a type safe list...
Its something like this....
Here the compiler accepts such a line but warns you that your list x2 which is supposed to be typesafe "may not be typesafe"... (true in this case..)
say I comment the line 1, it still would warn you...
GenericType<-NonGenericType :compiler warning
NonGenericType<--GenericType :Again a compiler warning
Generic<-Generic :No probs
NonGeneric<-NonGeneric : No probs
Regards,
Vishwa