StackOverflowError (infinite loop)

It is written in the technical book that it is useless because it will be an infinite loop, and I investigated how to actually make an infinite loop.

public static void add(){
    add();
}

To put it simply, this results in an infinite loop. Declare a function and call the same function inside it. Then, add () keeps calling add (), resulting in an infinite loop.

On eclipse, java.lang.StackOverflowError Error statement appears and ends.

In other words, an error will occur if the stack area is full and overflows.

According to Java Platform, Standard Edition 7 API specifications Thrown when the application recurses too many times and a stack overflow occurs.

It seems to be this way. In my case, it stopped on its own, but if it didn't stop, ctrl + c, ctrl + z, or Esc key Seems to be effective.

Recommended Posts

StackOverflowError (infinite loop)
Scanner Infinite loop until normal input
Java study # 5 (iteration and infinite loop)
Loop statement
Ruby conditional branch (case, while, infinite loop, break)