Anyone else having problems with the 1.5 beta?

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
 
S

Steve Burrus

Jim, to answer your question : >>"Is there an environment variable that
needs to be set??"<<, the very obvious response back to you would be
"Did you set the right/correct env. variable for both the PATH and the
CLASSPATH???" (Just a thought! :))

**********************************************************************************************************************
 
M

Mladen Adamovic

AFAIK if you want to kompile java 1.5 source under
Java 1.5 beta compiler you must run it with the -source 1.5 parameter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top