Reputation: 655
I recently downloaded IntelliJ for Java programming, and while testing it out I realized it wasn't using the right version of Java. I have this code:
public class Main {
public static void main(String[] args) {
String question = "0";
switch (question){
case"0":
break;
}
}
}
I compiled it and it gave me this error in the console:
Information:Using javac 1.8.0_25 to compile java sources
Information:java: Errors occurred while compiling module 'Game'
Error:(9, 16) java: strings in switch are not supported in -source 1.6
(use -source 7 or higher to enable strings in switch)
I went in File -> Project Structure -> Project SDK
and saw that is was using 1.7.0, which should work, since using Strings
in a switch was implemented in Java 7. I changed it to 1.8.0, and the problem is still there, any help?
Upvotes: 0
Views: 751
Reputation: 15755
Typically, you have to tell Intellij which language level you would like as well.
Right under Project SDK is the option Project Language Level
. Try changing that to 7 or 8.
Upvotes: 3