Miel
Miel

Reputation: 3477

Syntax error on ArrayList declaration

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.

Upvotes: 1

Views: 3961

Answers (3)

CPerkins
CPerkins

Reputation: 9018

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.

Upvotes: 0

Zed
Zed

Reputation: 57668

Your project is probably set to Java 1.4 target.

Upvotes: 2

DarkSquid
DarkSquid

Reputation: 2656

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

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

Upvotes: 2

Related Questions