JVamcas
JVamcas

Reputation: 132

assert keyword(cannot resolve symbol assert)

   GridBlock firstBlock =grid.getEntranceBlock(); //enter through entrance
        assert(firstBlock!=null);

The above assert keyword is flaged by the IDEA and I don't understand why. If i try to compile i get an warning "Warning:(83, 25) java: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier (use -source 1.4 or higher to use 'assert' as a keyword)". As I understand you can use assert without having to import anything. Now i don't understand what I am missing. I tried download new JDK but it didn't help. I m using Intellij

Upvotes: 0

Views: 2436

Answers (1)

yoshi
yoshi

Reputation: 171

Check what "language level" your project is using: File > Project Structure > Project > Project language level

You might be on a very old level for some reason. If there's no reason to be on it, just try increasing it to something more modern -- this will also give you other very useful language features.

Upvotes: 1

Related Questions