0
点赞
收藏
分享

微信扫一扫

内部类。。

Raow1 2022-03-12 阅读 34
java

package oop.Demo10;

public class Test {
    public static void main(String[] args) {
        Apple apple = new Apple();
        //没有名字初始化类,不用将实例保存到变量中~
        new Apple().eat();
        new UserService(){

            @Override
            public void hell() {

            }
        };
    }
}
class Apple{
    public void eat(){
        System.out.println("1");
    }
}
interface UserService{
    void hell();
}

举报

相关推荐

0 条评论