Sam Acropolis wrote:Maybe the return is causing the problem probably....
No. The call to toString is causing the problem. You call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString. The last thing this call to toString does is to call toString...
It's known as recursion.
What
you should be doing is storing the value returned from your calls to Integer.toString() in a variable.
Then instead of printing out all that stuff at the end of your toString method you should be storing it in a String along with the value returned from Integer.toString() and then returning that String.
You then print out what toString returns in your main method.