This week's book giveaway is in the Design and Architecture forum. We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line! See this thread for details.
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)
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%)
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad: