Friday 15 March 2013

Converting java 8 lambda expression to work in java 7 -


Trying to change this section of code to get rid of lambda quote, so it works in Java 7 Will be able to.

  System.out.println (nicksGraph.findPath (nicksGraph.nodeWith (new coordinate (0,0)), (a-> a.getX () == 3 & amp; Amp; A.getY () == 1), New Priority Queue & Lt; Node & Lt; Coordination & gt; Integer & gt; (Funkkotal));  

I have looked around, but maybe I do not understand it correctly. In Java 8, Lambda Expression is an option for an anonymous Inner class implementing a functional interface.

"post-text" itemprop = "text">

It seems that you are using repatriation , because the expression is a boolean Is.

It was introduced in Java 8, so you can recreate it yourself You will not be able to create default or static methods, therefore Just keep the functional interface method.

  Public Interface & lt; T & gt; {Public Boolean Test (TT); }  

Then, replacing lambda expression with anonymous class declaration.

  System.out.println (nicksGraph.findPath (nicksGraph.nodeWith (new coordinate) (0,0)), // Replacement anonymous Inner class here. New launcher & lt; cordineate & gt; ; () {@ Override Public Boolean Test (Coordinate A) {// Return Lambda Express Return. A.getX () == 3 & amp; amp; a.p.a.a.getY () == 1;}}, New Priority Queue And lieutenant; node lieutenant; coordinate>, integer & gt; (functotal));  

No comments:

Post a Comment