It is just a funny question. Not a real code for production. I do not want to fix it. I just want to understand this strange behavior. I have the code that should print "1" in each line. Actually, it is false. I get the strange result like "11111111" in one line.
class Scratch
{
public static void main( String[] args )
{
method();
}
static void method()
{
try
{
System.out.println(1);
method();
}
catch ( StackOverflowError e )
{
method();
}
}
}
Output could be the following:
1
11111
1
11111
1
1
1
1
1
11111111
1
11111