Can anybody tell me what is StackOverflowError in Java ?
A stack overflow occurs when too much data is put on the stack, which is a limited resource.
Here's an example:
public class Overflow {
public static final void main(String[] args) {
main(args);
}
}
That function calls itself repeatedly with no termination condition. Consequently, the stack fills up because each call has to push a return address on the stack, but the return addresses are never popped off the stack because the function never returns, it just keeps calling itself.
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