Consumer<Object> print = System.out::println;
// ...
print.accept("Hello, World!");
// ...
print.accept("Hello, World!");
--------------------------------------------------
interface Interf
{
public Sample m1();
}
public class Test implements Interf {
public Sample m1()
{
return new Sample();
}
//Constructor Reference
Interf i = () -> new Sample();
Interf i1 = Sample::new;
}
------------------------------------------------------------------------------
interface Interf
{
public void m1();
}
public class Test {
public void m2()
{
System.out.println("Method Reference");
}
public static void main(String[] args) {
Interf i = () -> System.out.println("By Lambda Expression");
i.m1();
Test test = new Test();
Interf i1 = test::m2;
i1.m1();
}
}
No comments:
Post a Comment