Java 7 switch statement, string does not work

According to the Java tutorials, in Java se 7 and later, you can use string objects in expressions of switch statements

String s = ...
switch(s){
    //do stuff
}

But is this true? I have installed JRE and added it to the build path of the eclipse project, but I received the following compile time error:

In addition, I think I have configured it correctly because I can use its Java nio. file. Files class and jlayer

Any ideas?

Solution

Although the JDT team does implement the switch on string feature, support for Java 7 will not be available in eclipse 3.7 1 before:

See bug 288548:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>