What is the maximum level of inheritance in Java?

I was wondering if there is a finite amount of time that I can inherit for a class? Or what factors can affect this?

+5
java oop
source share
5 answers

Read it (his pleasure)

The system is out of resources. Consult the following stack trace for details. java.lang.StackOverflowError 
+13
source share

For all practical applications, Java inheritance trees can grow to infinite size.

+4
source share

There is no specific limit to the specification.

There is probably an implementation-specific limitation, if only that you are limited by available memory (class information must be stored somewhere).

And if you ever reach this limit, your design is still broken (anything that comes in double digits is definitely a code smell).

+3
source share

If the class is final , you cannot inherit it.

In addition, you can have endless inheritance trees. You can also endlessly implement using many interface classes.

0
source share

No restrictions indicated. For all practical purposes, it is infinite.

0
source share

All Articles