java和Superclasses中的继承(Object,Class) [英] Inheritance in java and Superclasses(Object, Class)
问题描述
是 java.lang.Object
所有自定义类/对象的父类是否隐式继承?我以为java不支持多继承。我问的原因是,如果我已经继承自另一个类在我的自定义类,再次java是强制隐藏继承的 java.lang.Object
在它的顶部,是不是多继承?
Is java.lang.Object
superclass of all the custom class/objects inherited implicitly? I thought java didn't support multiple inheritance. The reason I ask is if I already inherit from another class in my custom class and again java is forcing implicit inheritance of java.lang.Object
on top of it, is it not multiple inheritance?
此外,java.lang.class Class也是所有自定义类/对象的超类?如果不是,在java反射中,我们可以获得任何类传递的类的类型或调用isInstance任何对象?
Also, is java.lang.class Class also the superclass for all custom classes/Objects? If not, how in java reflections we can get the type of class for any class passed or call isInstance on any object?
推荐答案
一切都是一个对象,说你可以看到这样的结构:
Everything is an Object, that said you could see the structure as this:
Object
Animal
Cat
而不是这样:
Object Animal
Cat
其中 Cat
扩展了两者,它不像最后一个例子,但它 Cat
c $ c> extends 扩展 对象 code>。
Where Cat
extends both, it's not like this last example, but it's Cat
that extends
Animal
which extends
Object
.
这篇关于java和Superclasses中的继承(Object,Class)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!