so I'm quite new to java and I have no idea how this is happening but when I force the program to crash due to stack overflow my catch method appears to catch it but is stuck in an infinite loop, not sure why or how to fix it. Could anybody help me out? I'd really appreciate it.
private static int Fibonacci(int n)
{
int fibVal = 0;
try
{
if (n == 0)
{
fibVal = 0;
}
else if (n == 1)
{
fibVal = 1;
}
else
{
fibVal = Fibonacci(n - 1) + Fibonacci(n - 2);
}
}
catch (StackOverflowError e)
{
System.out.println("This was another stack overflow, probably too high an input");
}