SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Sandhya Bhaskara<br />SCJP 1.4,SCWCD 1.4,SCBCD 1.3,SCJP 6
Originally posted by Sandhya Bhaskara:
Ankit,
In your example you were doing a get on stringList .What if you try to add an object to stringList? Even though the reference(stringList) is typed, the actual list itself is not typed.
In short my question is what is the difference between the below two statements
1. List<String> stringList = new ArrayList();
only reference variable is typed
2. List<String> stringList = new ArrayList<String>();
Both the variable and the object are typed
If the above two statements are not the same, how does add works in the first case( I know in the second case compiler makes sure you can add only string objects)
Thank you
Sandhya
Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
Is there any other difference??
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
Thanks,<br />Subhasish
------------------------
Bob
SCJP - 86% - June 11, 2009