您如何解释代码中的节目是哪种类型的对象?
当我创建一个实现抽象方法的接口对象(通过匿名类)。我创建哪种类型的对象? 用一个示例,将更好地理解
public class Class1{
public static void main(String...args){
Interface1 object1= new Interface1(){
@Override
public method1(){
System.out.println("im the method");
}
}
System.out.println(Object1.getClass());
}
这个问题将返回类别1。你怎么解释一下?
我的疑问的解释
when I create an interface object implementing the abstract methods (through anonymous classes). What type of object am I creating?
with an example the question will be better understood
public class Class1{
public static void main(String...args){
Interface1 object1= new Interface1(){
@Override
public method1(){
System.out.println("im the method");
}
}
System.out.println(Object1.getClass());
}
this returns the class Class1. how can you explain this?
an explanation of my doubt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论