62,624
社区成员
发帖
与我相关
我的任务
分享
class Adder
{
int i;
int j;
public Adder(int i, int j)
{
this.i = i;
this.j = j;
}
public int add()
{
return i + j;
}
}
interface AddInterface<T>
{
public int result(T t);
}
public class ThreadState
{
public static void main(String[] args)
{
Adder obj = new Adder(11, 22);
int res = getRes(obj, Adder::add);// 33
}
public static int getRes(Adder add, AddInterface<Adder> ops)
{
return ops.result(add);
}
}
Hero hero = new Hero(null, 0, 0);
filter(heros, hero::matched);//要用作用域调用对象方法,需要具体的对象。