The warning is because raw List reference is referenced to parametrized LinkedList.
LinkedList parametrization means that you have an intent to explcitly restrict collection items to String type, but the raw reference spoils all the generic effort and allows to add any object (like Integer on line 7), despite of LinkedList parametrization
SCJP 6.0(95%), SCWCD 5(94%), SCJD (working on B&S v.2.3.1)
Joined: Jul 06, 2009
But the rule is:
Non Generic ref. type + Generic instant --> compiles w/o warning
Generic ref.type + Non Generic instant --> compiles with warning
Ankit Garg wrote:
This line of code does not generate any compiler warning. How did you compile your code?? Did you use any IDE??
No i am trying in notepad and command prompt.
The warning will occur only if you are trying to add something.
Every time when you try to add something to a non parameterized collection , the warning will occur. As such a list can accept any type of object, this is the compiler's way to tell you that you must pay attention to what you are adding to the list.
SCJP 6.0 (88%)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com