Java:一个类本身是一个子类吗? [英] Java: Is a class a subclass of itself?
本文介绍了Java:一个类本身是一个子类吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个类可以是一个子类,如果它的内部类扩展外部类
所以该类不知何故扩展自己没有抛出任何异常。
A class can be a "subclass" of itself if its inner class extend the outer class so the class is somehow extending itself without throwing any Exception. So, does it really mean a class is also a subclass of itself?
谢谢。
推荐答案
类不是自身的子类。内部类可以是某个其他类的子类,但这是一个单独的类。你可以通过比较调用getClass()时获得的类实例来验证这一点。
A class is not a subclass of itself. An inner class could be a subclass of some other class, but that is a separate class. You can verify this by comparing the Class instances you get when you call getClass().
这篇关于Java:一个类本身是一个子类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文