我有一个关于Java 8的问题Runnable.
public static void main(String[] args) {
Runnable r1 = Test::t1;
Runnable r2 = Test::t2;
Runnable r3 = Test::t3;
}
public static void t1() {
}
public static String t2() {
return "abc";
}
public static String t3(String t) {
return t;
}
Run Code Online (Sandbox Code Playgroud)
正如代码所示,我理解r1是对的,r3也是错的,但我不明白为什么r2也是对的.任何人都可以帮我理解吗?
byte[] a = {1,2,3};
System.out.println(Stream.of(a).count());
Byte[] b = {1,2,3};
System.out.println(Stream.of(b).count());
Run Code Online (Sandbox Code Playgroud)
结果是1和3,为什么?