Anyone else having problems with the 1.5 beta?

From: Jim (jkorman_at_alltel.net)
Date: 02/29/04


Date: Sun, 29 Feb 2004 04:34:19 GMT

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



Relevant Pages

  • Re: uninitialized variable
    ... public static void main(String args) { ... int y = 10; ... But as far as the compiler ...
    (comp.lang.java.programmer)
  • Re: Compiler trick
    ... The fact that the compiler is not sentient and does not possess a human ... public static void main(Stringargs) { ... if (obj instanceof MyClass) { ...
    (comp.lang.java.programmer)
  • Re: Question on syntax
    ... well, although when mixed with some generics signatures, this may ... require some explicit input to the compiler as to what you really want. ... args) ... public static void main(String... ...
    (comp.lang.java.help)
  • Re: macro equivalent to "format" but with changed line endings
    ... `(format nil,(string-upcase str),arg) ... OK, I've never tried compiler macros before, but I'll give it a shot... ... (defun ms-format (dest fmtstr &rest args) ... (stringp (second fmtstr)) ...
    (comp.lang.lisp)
  • Re: abstract static methods (again)
    ... interfaces, ... public static void run{... ... It would work by the compiler generating an extra class when it saw ... also wanted to enforce constructors, but they could be replaced by static ...
    (comp.lang.java.programmer)