Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Is a class a subclass of itself?

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?

Thanks.

like image 595
Sajal Dutta Avatar asked Dec 05 '22 06:12

Sajal Dutta


1 Answers

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().

like image 144
Mr. Shiny and New 安宇 Avatar answered Dec 16 '22 16:12

Mr. Shiny and New 安宇