I’m implementing an interface.
I have a declaration
private T[] entry;
then, I have the constructor as such:
public Example()
{
@SuppressWarnings("unchecked")
entry = (T[])(new Comparable[10]);
}
My compiler is telling me that:
<identifier> expected
at
entry = (T[])(new Comparable[10]);
Haven’t I already done this during the declaration?
That error is caused by the
@SuppressWarningsline.You cannot apply an annotation to an arbitrary line of code.
Instead, you need to apply it to the constructor.