forked from adamldavis/hellojava8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunc.java
More file actions
27 lines (16 loc) · 672 Bytes
/
Func.java
File metadata and controls
27 lines (16 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import static java.lang.System.out;
import java.util.function.*;
public class Func {
static Function<String, String> f = (name) -> {return name + "-";};
static Function<String, Integer> leng = (name) -> {return name.length();};
static Function<String, Integer> leng2 = String::length;
//static Supplier<Func> ff = ()-> new Func();
public String name() { return "foo"; }
public static void main(String ... args) {
String[] strs = {"foo", "bar", "bash" };
for (String s : strs) out.println(leng.apply(s));
//for (String s : strs) out.println(leng2.apply(s));
Function<Func, String> name = Func::name;
out.println(name.apply(new Func()));
}
}