This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center




7年前关闭。



public interface IMethodCallback
{
    boolean Execute();
}

...

IMethodCallback callback = new IMethodCallback
            {
                boolean Execute()
                {
                    return false;
                }
            };

这会导致错误。如何在Java中制作类似的东西?

最佳答案

您会错过构造函数的括号:

IMethodCallback callback = new IMethodCallback()
{
    public boolean Execute()
    {
        return false;
    }
};

10-07 22:41