J
Jim
I have tried the following code
import java.util.*;
public class FirstTest {
public static void main(String [] args) {
ArrayList<String> a = new ArrayList<String>();
a.add("I");
a.add("hope");
a.add("that");
a.add("this");
a.add("works");
for (String s : a) { System.out.println(s); }
}
}
and get the following errors from the compiler
C:\JavaSource\Java_1.5>javac FirstTest.java
FirstTest.java:8: '(' or '[' expected
ArrayList<String> a = new ArrayList<String>();
^
FirstTest.java:16: ';' expected
for (String s : a)
^
FirstTest.java:20: illegal start of expression
}
^
3 errors
*******************
I was going to post the above problem, then found the
solution. Just to pass on the above code seems to
want
C:\JavaSource\Java_1.5>javac -source 1.5 FirstTest.java
Then it compiles and runs fine.
?? Is there an environment variable that needs to be set??
Jim
import java.util.*;
public class FirstTest {
public static void main(String [] args) {
ArrayList<String> a = new ArrayList<String>();
a.add("I");
a.add("hope");
a.add("that");
a.add("this");
a.add("works");
for (String s : a) { System.out.println(s); }
}
}
and get the following errors from the compiler
C:\JavaSource\Java_1.5>javac FirstTest.java
FirstTest.java:8: '(' or '[' expected
ArrayList<String> a = new ArrayList<String>();
^
FirstTest.java:16: ';' expected
for (String s : a)
^
FirstTest.java:20: illegal start of expression
}
^
3 errors
*******************
I was going to post the above problem, then found the
solution. Just to pass on the above code seems to
want
C:\JavaSource\Java_1.5>javac -source 1.5 FirstTest.java
Then it compiles and runs fine.
?? Is there an environment variable that needs to be set??
Jim