This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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.