Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write equivalent of lambda expression in Java 1.7?

I have the following code in Java 1.8.

solver.plugMonitor((IMonitorSolution) () -> solution.record(solver));

How can I convert this to Java 1.7 code without lambda?

like image 576
Phil Avatar asked Dec 20 '14 05:12

Phil


1 Answers

The plugMonitor method requires an argument of type IMonitorSolution, with some method YMethod that has no arguments :

solver.plugMonitor (new IMonitorSolution () {
                        public void YMethod () {
                            solution.record(solver);
                        }
                    });

Thanks to @Boann for correcting my error.

like image 68
Eran Avatar answered Sep 30 '22 13:09

Eran