This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Line 21 will lead to either an infinite loop or a StackOverflowError; I think it's the latter. The reason is quite clear: you called move with two arguments. An exception occurs. What do you do? You call the method with the same two, unmodified arguments. As a result, the same exception will occur, and you call the method with the same two, unmodified arguments. As a result, the same exception will occur, etc.
Line 29 will also cause the infinite loop or a StackOverflowError, since you're again calling the same method with the same, unmodified arguments.
In recursion, you usually call the same method, but with different arguments. Somewhere in the method it will perform a check that will lead to a path that does not call the same method, thereby ending the recursion.
I was able to sort out that problem.
Wat i did was make two variables static, that solved the problem.
Thanks for the help guys
Joined: Oct 13, 2005
Which two variables are static? Why did you make them static? That changes the behaviour of the variable, which may cause you problems later.
Changing the design of your class as a workaround because a control structure doesn't work sounds very suspect to me.