在Java 8中,lambda表达式替代了实现功能接口的匿名内部类。看起来您在这里使用的是
Predicate,因为表达式是
boolean。
该
Predicate接口是Java
8中引入的,因此您需要自己重新创建它。您将无法创建
default或
static方法,因此只需保留功能性接口方法即可。
public interface Predicate<T>{ public boolean test(T t);}然后,将lambda表达式替换为匿名类声明。
System.out.println(nicksGraph.findPath( nicksGraph.nodeWith(new Coordinate(0,0)), // Replacement anonymous inner class here. new Predicate<Coordinate>() { @Override public boolean test(Coordinate a) { // return the lambda expression here. return a.getX()==3 && a.getY()==1; } }, new PriorityQueue<Node<Coordinate>, Integer>(funcTotal)));


