什么是这种类型的初始化调用,为什么使用它? [英] What is this type of initialization called and why is it used?
本文介绍了什么是这种类型的初始化调用,为什么使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Animal是一个用户定义的类。
Animal is a user defined class here.
Animal D = new Animal("Leo") {
@Override public void makeNoise() {
System.out.println("Roar!");
}
}; D.makeNoise();
推荐答案
它叫做匿名类,用于同时定义类和任何重写的方法。
Its called an anonymous class and used to define the class and any overridden methods at the same time.
这篇关于什么是这种类型的初始化调用,为什么使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文