This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Infinite Loop in my code.

 
Vincent Mule
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you saw my earlier post, we have to navigate a 10x10 array using 1's as a path. When a 1 is selected, we have to change the current position to -1 so that way we don't keep retracing our steps. When I run the program, it keeps saying STEPPED TO [2,3] over and over again. Can someone please identify where my infinite loop is? I can't seem to find it.

 
Ivan Franko
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After each step, you don't change coordinates, why?

I think it is a root of the issue.
 
Vincent Mule
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I changed it to read


The changes in X and Y are reflected through the rest of the code, but I am still getting an infinite loop when attempting to move diagonally. It keeps jumping back and forth between spaces.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic