I wrote this (joke) code the other day seeing what would happen, but I got some really strange results:
class Foo{
public static void main(String[] args){
while(true)
recur();
}
public void recur(){
while (true){
try{
System.out.println("Hi ");
recur();
} catch (StackOverflowError e){
recur();
}
}
}
}
It just continuously prints out "Hi ", with no indication of stopping (I terminated the program after it ran for a full minute). Oddly, sometimes "Hi " gets printed out multiple times on one line (I counted 117 on one line). But, more importantly, the program keeps running, with no termination. Any ideas?