Sorry, I know nothing about your IDE.
This code works for me with 1.7:
String key = "ABC";
switch (key) {
case "ABC":
System.out.println("works"); //...
Type: Posts; User: Norm
Sorry, I know nothing about your IDE.
This code works for me with 1.7:
String key = "ABC";
switch (key) {
case "ABC":
System.out.println("works"); //...
If you use Java 1.7 to compile(javac) it and execute(java) it, it should work.
The IDEs message looks like it doesn't know about the new switch in java 1.7
@Sean4u - your syntax looks right.
What error message do you get from the 1.7 javac compiler?
You'll have to get java 1.7 for that style of switch statement. Until then only integers work.
A work around is a chain of if/else if/else if /else statements to compare the Strings.
Be sure to...