想问下这个为什么会报错

package test8;
interface fire{
public void Fireup(); //{
//System.out.println("点燃火柴");
//}
}
public class Match {
public int count = 0;

   fire a = new fire() {

    @Override
    public void Fireup(int count) {
        if(count == 0)
        {
            System.out.println("fire up the match");
        }
        else return;
        // TODO 自动生成的方法存根
        
    }
};
   

}

img

package com;
interface fire{
    public void Fireup(); //{
//System.out.println("点燃火柴");
//}
}
public class Match implements fire{
    public int count = 0;

    @Override
    public void Fireup() {
            if(count == 0)
            {
                System.out.println("fire up the match");
            }
            else return;
            // TODO 自动生成的方法存根
        }
}

直接实现接口implements fire
不能new fire 接口

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632