Out of curiosity I came to write the following method:
public Object getObject() {
return this.getObject();
}
Why would Java allow me to write this? This method would never return any Object
and would result in a StackOverflow Error
.
It shouldn't stop you from doing it - this is just bottomless recursion, but it could've been a regular one. The compiler doesn't need to go and understand to code to guess if it's properly defined recursion or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With