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: 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: C# very optimisation
    ... is a struct. ... When ++ is used on some other type object, the oper++ is done out-of-line, and so, the compiler cannot remove it. ... public static void print(string prefix, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: macro equivalent to "format" but with changed line endings
    ... OK, I've never tried compiler macros before, but I'll give it a shot... ... when I define it as a compiler macro as above, that's when I get the "too few arguments" message. ... (define-compiler-macro ms-format (&whole form dest fmtstr &rest args) ... This is just very strange -- the fact that the previous simple macro code seemed to work except that the compiled code didn't keep the expansion on the static strings is very odd. ...
    (comp.lang.lisp)