Java version (switch)

Hello,

I posted my submit to http://www.codechef.com/problems/A3/.
It works locally, but on this site I have compilation errors:

Main.java:75: incompatible types found : java.lang.String required: int switch (operator) { ^ Main.java:113: incompatible types found : java.lang.String required: int switch(operator) { ^ Main.java:189: incompatible types found : java.lang.String required: int switch(operator) { ^ 3 errors

They are connected with switch statement, in which I use String as argument. As far as I understand, this construction is not available in Java 6, but it is implemented in Java 7 (http://stackoverflow.com/questions/338206/switch-statement-with-strings-in-java). But on the CodeChef wiki page I see information that the Java compiler version is javac-1.7.0_25 (List of Compilers | CodeChef). Is there something I missed?

Thanks to look at this.

2 Likes

Thank you for reminding this, I reported this earlier, now I’ll write to admins and let you know :wink:

2 Likes

Yeah, I would you recommend you to avoid using features introduced in Java 7 until further notice, I once tried to use the method [Long.compare()][1] and it did not compile.

[1]: Long (Java Platform SE 7 )(long, long)

1 Like

Yeah, those methods are really cool, I’m using those in comparators, works fine in TopCoder arena…

Yeah, TopCoder updated Java a while ago and even the plugin eclipsecoder was updated to the Java 7… It would be nice if @admin could say something about the compilation errors and if Java was really updated, some of those compilation errors are really tricky to catch…