Index Page : Link
Donate : Link
Medium Blog : Link
Applications : Link

package com.codeFactory.methodAndConstructorReference;
class Sample {
Sample() {
System.out.println("Sample.Sample()");
}
}
interface Interf {
public Sample get();
}
// Using Lambda Expression
public class Test {
public static void main(String... args) {
Interf i = () -> {
return new Sample();
};
Sample s = i.get();
}
}
// Using Constructor Reference
public class Test {
public static void main(String... args) {
Interf i = Sample::new;
Sample s = i.get();
}
}
Output :
Sample.Sample()
Syntax for Constructor Reference :
- classname :: new
- e.g. Sample :: new

whoah this blog is excellent i really like studying your articles. Keep up the good paintings! You understand, many persons are searching round for this info, you could help them greatly.
LikeLiked by 1 person
Thank you Ramiro Leuze
Please check new blog https://bit.ly/31989Yt
Like | Download | Share
LikeLike