Skip to main content

test jdk 7 new features

3 replies [Last post]
jsanza
Offline
Joined: 2009-06-26

Hello,

What can i do to compile

class A
{
public static void main(String a[])
{
String s = "test";
switch(s) {
case "foo": break;
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
caclark
Offline
Joined: 2005-02-24

Hand code the class outside of an IDE, using a text editor, and hand compile it using javac. Language changes regarding JDK 7 will not be available in any IDE until they are definite.

jsanza
Offline
Joined: 2009-06-26

[jsanza@darkstar tmp]$ javac -source 7 A.java
A.java:6: incompatible types
switch(s) {
^
required: int
found: String
1 error
[jsanza@darkstar tmp]$

any ideas , what am i doing wrong ?

[jsanza@darkstar tmp]$ javac -version
javac 1.7.0-ea
[jsanza@darkstar tmp]$

caclark
Offline
Joined: 2005-02-24

Not sure if the new language features have been included in the jdk 7 build yet. Possibly not, need to check the release notes per jdk 7 release.