This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
My compiler detected recursive calls, too. However, this was compiled and ran until reaching StackOverflowError: Why are constructors a special case then? Obviously, a method can call itself (to implement recursion). So, are two methods allowed to call each other recursively for the same reason? Or is it just too much of a hustle for compiler to track recursive calls (especially in case of more than two methods)? Thanks
A recursive method call should have some terminating condition. If a programmer fails to provide that terminating condition, then that is his error and will result in a stack overflow.
A constructor, however, does not normally have a terminating condition, although I suppose you can simulate one by throwing an exception. Also, since a constructor does not have a retrun value, I don't know why a program would ever need to call a constructor recursively.