Then you might experience a compiler warning similar to the following one:
Type safety: The expression of type List needs unchecked conversion to conform to ListAs the compiler tries to statically check the type safety there is no way it can find out whether the raw type list actually contains only instances of YourType.
The solution is to add the following annotation in front of the method for which the warning is reported:
@SuppressWarnings("unchecked")Note that the generic ArrayList<> is always compiled into the raw type ArrayList. The same applies for all other collections in java.util. The reason is that this type information is removed in order to stay backward compatible. Therefore in Java 5 all instances of ArrayList
For C++ and also for .NET 2.0 and later the designers chose a different solution. In C++ each instance of the template ArrayList
3 comments:
You can also cast the type to be unknown type Example:
Enumeration <?> parameterNames=req.getParameterNames();
You can also cast the type to be unknown type Example:
Enumeration <?> parameterNames=req.getParameterNames();
Is there any other way to get rid of this warning?
Post a Comment