1

I've got the following code:

import java.util.*;

public class Group {
    public static void main(String[] args) {
    ArrayList<Integer> list = new ArrayList<Integer>();
    }
}

Eclipse (3.0.0) complains about the ArrayList declaration: syntax error on token "(", on both tokens "<", and then on token "=". I'm using java 1.5.0_07.

What am I doing wrong?

Thanks, regards, Miel.

3 Answers 3

2

Set your JDK level to >= 5.0 to enable support for generics.

It's at Project -> Properties -> Java Compiler -> Compiler Compliance Level

Sign up to request clarification or add additional context in comments.

2 Comments

That does the trick, but you need Eclipse version >= 3.1 to get levels > 1.4. For Eclipse 3.5 the default level is set to 1.5. (And that actually is what you mean with 5.0, I guess.)
Oops; I see you said Eclipse 3.0; did not realize that this option is new to 3.1.
2

Your project is probably set to Java 1.4 target.

Comments

0

Sounds like you've installed 1.5 on your box, but not in Eclipse. To fix that, go to Window->Preference->Installed JREs, and add your installed JRE.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.