I was wondering if there is a finite number of time that I can inherit a class? Or what are the factors that can influence this?
For all practical applications, inheritance trees in Java may grow to infinite size.
There's no specific limit in the specification.
There's probably a implementation-dependent limit, if only in that you're limited by the available memory (class information needs to be stored somewhere after all).
And if you ever reach that limit, your design is broken anyway (anything that goes into the double digits is definitely a code smell).
Read this (Its fun)
The system is out of resources. Consult the following stack trace for details. java.lang.StackOverflowError
If a class is final
, you cannot inherit it.
Besides that, you can have infinitely inheritance trees. You can also infinitely implement
many interface classes too.
There is no limit specified. For all practical purposes, it is infinite.