What does "->" do in Java?
I looked at several java tutorials and was not sure what the "->" did and could not find anything on Google about this.
Here is the code I saw that used it:
myShapesCollection.stream() .filter(e -> e.getColor() == Color.RED) .forEach(e -> System.out.println(e.getName())); This is the syntax used for lambda expressions available in Java 8.
For example, filter expects Predicate and e -> e.getColor() == Color.RED functionally equivalent:
new Predicate<Shape>() { public boolean test(Shape s) { return s.getColor() == Color.RED; } }