Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Switch case using Strings

$
0
0

Hello,

 

I have a problem with switch cases in IntelliJ. Since 1.7 Java supports switch case using Strings.

In IntelliJ the compiler tells me " Incompatible types. Found 'Java.lang.String', required: 'byte, char, short or int' ".

In eclipse is everything working properly. I reinstalled all my JRE and JDK, also tried Java 8 Early Access. I'm using IntelliJ 12.1, but I also tried IntelliJ 13 EA. But always the same problem with switch case.

 

Code:

 

String s = "test";

switch (s) {

     case "test" : System.out.println("test");

}

 

Thanks in advance!


Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>