How can I suppress this warning:
LinkedList is a raw type. References to generic type LinkedList<E> should be parameterized
This did not work:
@SuppressWarnings("unchecked")
How can I suppress this warning:
LinkedList is a raw type. References to generic type LinkedList<E> should be parameterized
This did not work:
@SuppressWarnings("unchecked")
@SuppressWarnings("rawtypes") is the annotation used to suppress this.
Although you would be better off parameterizing, if you are not working with legacy code.
if you are using eclipse the hover over the text (probably yellow underlined) and do a ctrl+1 to look for the options available to fix the issue.
But you should always parameterized your lists.
If you don't want to parameterize then use
@SuppressWarnings("rawtypes")
Depending on which version of java you are using, it sounds like you need to change your linked list instantiations.
Raw types.
When source code is compiled for use in Java 5.0 that was developed before Java 5.0 and uses classes that are generic in Java 5.0, then "unchecked" warnings are inevitable. For instance, if "legacy" code uses types such as List , which used to be a regular (non-generic) types before Java 5.0, but are generic in Java 5.0, all these uses of List are considered uses of a raw type in Java 5.0. Use of the raw types will lead to "unchecked" warnings. If you want to eliminate the "unchecked" warnings you must re-engineer the "legacy" code and replace all raw uses of List with appropriate instantiations of List such as List , List , List , etc. All "unchecked" warnings can be eliminated this way.
In source code developed for Java 5.0 you can prevent "unchecked" warnings in the first place by never using raw types. Always provide type arguments when you use a generic type. There are no situations in which you are forced to use a raw type. In case of doubt, when you feel you have no idea which type argument would be appropriate, try the unbounded wildcard " ? ".
In essence, "unchecked" warnings due to use of raw types can be eliminated if you have access to legacy code and are willing to re-engineer it.
http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#FAQ001