Skip to main content

On Lambda (lambda-8-b39) List.parallel() error: cannot find symbol

No replies
Joined: 2012-06-05
Points: 0

The compiler states that parallel method not find it as a symbol.
Without using parallel, all would be sequential and able to compile.
This is my code:
import java.util.ArrayList;
import java.util.List;

public class Parallelism {
public static void main(String... args) {
final class Student {
private final int year;
private final int score;

Student(int year, int score)
{ this.year = year;
this.score = score; }

public int getGradYear()
{ return year; }

public int getScore()
{ return score; }

List students = new ArrayList();
for (int i = (int) -1E6; i < 1E6; ++i)
students.add(new Student(i, i));

//!!!!!!!!!!!!!!!!!!!!!! Problem here !!!!!!!!!!!!!!!!!!!!!!!!
int highestScore = students.parallel()
.filter(s -> s.getGradYear() == 2012)
.map(s -> s.getScore())
.reduce(0, Math::max);

System.out.printf("score %d", highestScore);