Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 55ca11f

Browse files
Challenge 52.
Method reference, Constructor method
1 parent a1e3fd5 commit 55ca11f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package challenge51_60;
2+
3+
/**
4+
* broerSupplier.provideBroer(Integer.valueOf(3))---> Broer(int any) will be called because it is the best match
5+
*
6+
*/
7+
public class Challenge_52 {
8+
9+
public static void main( String[] args ) {
10+
BroerSupplier broerSupplier = Broer::new;/*no instantiation in that line*/
11+
short s =1;
12+
broerSupplier.provideBroer(s);//the construtur will be called in that line
13+
broerSupplier.provideBroer(10);
14+
broerSupplier.provideBroer(1);
15+
}
16+
17+
static class Broer{
18+
Broer(int any){
19+
System.out.println("int" + any);
20+
}
21+
22+
Broer(short any){
23+
System.out.println("short" + any);
24+
}
25+
Broer(Integer any){
26+
System.out.println("Integer" + any);
27+
}
28+
}
29+
private interface BroerSupplier{
30+
Broer provideBroer(int quantity);
31+
}
32+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /