Click here to watch in Youtube :
https://www.youtube.com/watch?v=CUad5eHBruo&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Instance method reference of an existing object| Method reference in Java 8 | Java method reference |
import java.util.function.Consumer; class Car { private String name; public Car(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public class Mechanic { public void fix(Car c) { System.out.println("Mechanic is fixing " + c.getName()); } public void execute(Car car, Consumer<Car> c) { c.accept(car); } }LambdaDemo.java
import java.util.function.Consumer; public class LambdaDemo { public static void main(String[] args) { final Mechanic mechanic = new Mechanic(); Car car = new Car("Honda Jazz"); // Using an anonymous class mechanic.execute(car, new Consumer<Car>() { public void accept(Car c) { mechanic.fix(c); } }); // Using a lambda expression mechanic.execute(car, c -> mechanic.fix(c)); // Using a method reference mechanic.execute(car, mechanic::fix); } }Output
Mechanic is fixing Honda Jazz Mechanic is fixing Honda Jazz Mechanic is fixing Honda JazzClick the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_Instance_method_ref_mechanic-app.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app/?at=master
See also:
Its really good blog and very information, we are tempo traveller rental company in Gurgaon providing tempo traveller in gurgaon for local and outstation, we have luxury tempo traveller in gurgaon you can rent 12 seater, 17 seater , 20 seater , 26 seater Tempo traveller gurgaon to outstation tours ~ JBL Tempo Traveller Rentals Delhi NCR ~ 9560075009
ReplyDeleteOur location :
Tempo traveller in Gurgaon
tempo traveller in noida for local and outstation, we have luxury tempo traveller in noida you can rent 12 seater, 17 seater , 20 seater , 26 seater Tempo traveller noida to outstation tours ~ JBL Tempo Traveller Rentals Delhi NCR ~ 8448336448
It's really nice and informative blog. We provide tempo traveller in Noida on rent at reasonable price.
ReplyDeleteIt's really nice and informative blog. We provide tempo traveller in Noida on rent at reasonable price.
ReplyDeleteHindi News, Latest News In Hindi, Hindi Samachar हिंदी न्यूज़, Breaking News Headlines Today. Hindi News (हिंदी न्यूज़) - हिंदी में पढ़िए देश, विदेश, खेल, मनोरंजन, राजनीति, क्राइम, ऑटोमोबाइल, टेक्नोलॉजी, शिक्षा, लाइफस्टाइल, क्रिकेट और ज्योतिष से सम्बंधित सभी समाचार SM Hindi News पर. अमर उजाला हिन्दी न्यूज़ पेपर, Get Breaking News Headlines in Hindi.
ReplyDeleteSm Hindi News
Hindi News
printer cartridge refilling near me
property dealers in sahibabad industrial area
Factory for rent in sahibabad industrial area