If the developer believes that the error can't be removed and that the code is type safe, then the annotation
@SuppressWarnings("unchecked")
can be used. This will tell the compiler not to report the warning. This should be used on the smallest scope as possible. So other unchecked warnings are not suppressed unnecessarily.If
@SuppressWarnings("unchecked")
is used but the code is not type safe, the code could generate a ClassCastException at runtime. So the developer must prove that the code is type safe and a comment should inform others why the annotation was used and why it is typesafe.Timothy Wright
No comments:
Post a Comment