forked from Apress/functional-interfaces-in-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSect7_Ex1.java
More file actions
21 lines (20 loc) · 839 Bytes
/
Sect7_Ex1.java
File metadata and controls
21 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package chapter4;
import java.util.function.*;
public class Sect7_Ex1
{
public static void main(String[] args)
{
DoubleToIntFunction di = x -> (new Double(x)).intValue();
DoubleToLongFunction dl = x -> (new Double(x)).longValue();
IntToDoubleFunction id = x -> (new Integer(x)).doubleValue();
IntToLongFunction il = x -> (new Integer(x)).longValue();
LongToDoubleFunction ld = x -> (new Long(x)).doubleValue();
LongToIntFunction li = x -> (new Long(x)).intValue();
System.out.println(di.applyAsInt(4.1));
System.out.println(dl.applyAsLong(5.2));
System.out.println(id.applyAsDouble(6));
System.out.println(il.applyAsLong(7));
System.out.println(ld.applyAsDouble(8));
System.out.println(li.applyAsInt(9));
}
}