Hi everyone. :)
I've got a question about looping and recurring in Java. Take a look at the two programs below:
Application A
Application BCode:public class Main {
public static void main(String[] args) {
while (true) {
System.out.println(": p");
}
}
}
Now, the first one runs fine. Fairly basic. But the second one is a problem, as I expected. The Stack Overflow exception is thrown after some time of execution. The same thing happens in C++.Code:public class Main {
public static void main(String[] args) {
go();
}
public static void go() {
System.out.println(": p");
go();
}
}
Application C
Is this just something that machines can't handle? Never ending recursion?Code:#include "stdafx.h"
#include <iostream>
using namespace std;
void go();
void main(int argumentCount, char **aguments)
{
go();
cin.get();
}
void go() {
cout << ": p\n";
go();
}
Just something that caught my attention.
Thank you. ;)

