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 44f8eaf

Browse files
Challenge 37.
BiFunction, Method References
1 parent f1b6a04 commit 44f8eaf

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package challenge31_40;
2+
3+
import java.util.function.BiFunction;
4+
5+
/**
6+
*
7+
* Method references
8+
* BiFunction and its apply method.
9+
*/
10+
public class Challenge_37 {
11+
12+
public static void main( String[] args ) {
13+
BiFunction<Integer, Integer, Integer> add = Challenge_37::add;
14+
int result = add.apply(10,20);
15+
16+
BiFunction<Double, Float, Integer> substract = Challenge_37::substract;
17+
result+= substract.apply(10D, (float)10D);
18+
System.out.println("result = " + result);
19+
}
20+
21+
static int add(double a, double b){
22+
return (int)(a+b);
23+
}
24+
25+
static int substract(double a, double b){
26+
return (int)(a-b+a);
27+
}
28+
29+
}

0 commit comments

Comments
(0)

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