Reputation: 165
I have this line of code in my Java program:
private final List<PhoneNumber> receivers = new ArrayList<>();
It signifies an error underneath the first < after 'new ArrayList'. ^
I'm running Eclipse and Windows 8 - 32-bit, could this be an encoding problem?
Upvotes: 1
Views: 6569
Reputation: 165
This was the solution for me:
this was 1.6 at first.
Had to download Eclipse Indigo RS2 for this one.
Upvotes: 0
Reputation: 939
The Diamond Operator, used to reduce the verbosity when using generics was added in JDK 1.7. The fact you're getting a syntax error probably means you're using an older version to compile this piece of code.
Either use JDK 1.7 to compile the code, or change to:
new ArrayList<PhoneNumber>();
Upvotes: 1
Reputation: 12843
Try this: You have to parametarize the type of object at both sides.
private final List<PhoneNumber> receivers = new ArrayList<PhoneNumber>();
Upvotes: 3