Problem with 'var' in IntelliJ IDEA

Hi guys
I have just signed up to the Course on “Ultimate Desigh Patterns” Mosh suggested install IntelliJ IDEA to follow along in Java code, which I did.

However, it reports “Cannot resolve symbol ‘var’” and shows it as color red when I attempt to enter ‘var’ in a line i.e.
var stopwatchname = new Stopwatch();

Currently my work around is to enter it as
Stopwatch stopwatchname = new Stopwatch();

I am not a Java man, but assume it a simple setting problem with IntelliJ IDEA - can any one help?
Kind regards
Dave Morris

Fixed my own problem - I appeared I was using an old version of the SDK (v1.8----).

  1. Go to Java site and download latest version of JDK.
  2. Select this latest version in Projects settings - see https://www.jetbrains.com/help/idea/sdk.html
  3. It then works.
1 Like

For the record, var was introduced in Java 10.

1 Like