zxz
zxz

Reputation: 729

@SuppressWarnings annotation not recognized by compiler/text editor

This seems incredibly basic, but as much as I search I can't find the solution.

I want to suppress a warning in java, by adding the @SuppressWarnings annotation, but the compiler doesn't accept it, nor does the text editor give it a special color. It's like annotations don't exist.

The text editor is Notepad++, and I simply compile from the command line with the newest JDK.

class Table<T> implements AbstractTable<T>{

    T[] elements;

    @SuppressWarnings()
    Table(int length){
        elementer = (T[]) new Object[lengde]; //this is why I want to suppress
    }
}

I must be missing out on something essential, what am I doing wrong?

Upvotes: 0

Views: 495

Answers (1)

sheltem
sheltem

Reputation: 3825

The annotation is not recognized by your editor because your editor doesn't have that functionality. Notepad++ has very basic syntax highlighting based on keywords and that's pretty much it. It has no compiler to know what @SuppressWarnings is supposed to be - or any annotation for that matter.

As to why the compiler rejects your annotation: You haven't defined the mandatory attribute value. You have to tell the compiler which warnings to ignore, like:

@SuppressWarnings("unchecked")

if you don't want to hear about unchecked conversions.

My suggestion would be to get a proper IDE like Eclipse, IntelliJ IDEA or NetBeans. Coding in Notepad++ is sufficient for a basic HelloWorld, but that's about it.

Upvotes: 2

Related Questions