package _5_26;
public class methodReference {
public static void main(String[] args) {
// Using object method reference
Function<String, Integer> fn1 = (String str) -> {
return str.length();
};
Integer aLength = fn1.apply("hello world");
System.out.println("String length is: " + aLength);
// Using method reference shorthand
Function<String, Integer> fn2 = String::length;
Integer bLength = fn2.apply("hello world");
System.out.println("String length is: " + bLength);
}
}
2667

被折叠的 条评论
为什么被折叠?



