EDIT: Found solution here: http://www.dreamsyssoft.com/java-8-lambda-tutorial/map-reduce-tutorial.php
I follow this guide:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html
When I get to the part where it uses the middle and middle functions, I get the following error:
UserAverageTest.java:68: error: cannot find symbol double average = users.parallelStream().filter(u -> u.age > 0).map(u -> u.age).average().getAsDouble(); ^ symbol: method average() location: interface Stream<Double>
I get the same error when calling the sum. For some reason, it seems like it is using Stream instead of the DoubleStream class. I am using the latest jdk with lambda enabled, which is linked in the tutorial.
Has anyone hit this problem and were able to solve it?
Here is a simple example that reproduces the problem:
class User { double age; public User(double age) { this.age = age; } double getAge() { return age; } } public static void main(String[] args) throws Exception { List<User> users = Arrays.asList(new User(10), new User(20), new User(30)); double average = users.parallelStream() .filter(u -> u.age > 0) .map(u -> u.age) .average() .getAsDouble(); }
source share