I had used @SuppressWarnings("unchecked")
like:
class SomeClass {
public static void main(String [] args) {
Vector v = new Vector();
@SuppressWarnings("unchecked")
v.addElement(new Integer(1_000_000));
// ...
On compilation using javac version 8.0, I got the following errors:
error: <identifier> expected
v.addElement(new Integer(1_000_000));
with the caret (^) pointing at the opening bracket of addElement
method and one more error message complaining missing semicolon(;). The second message showed the caret near the closing bracket of addElement
.
However, when I moved the @SuppressWarnings("unchecked")
above the class SomeClass{
, line, as in:
@SuppressWarnings("unchecked")
class SomeClass {
both the error messages disappeared automagically. This baffled me to any end. Is the positioning of @SuppressWarnings("unchecked")
so critical?