This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
So for example I have an array like this
and I want to move between the -1 and the 1. Lets say that coord is my current row and coord is my current column. How do I craft a statement that would allow me to move in between those numbers?
Edit, I figured it out.
for example, moving down and left, its arr[current number+1][current number+1]
Vincent Mule wrote:
and I want to move between the -1 and the 1. Lets say that coord is my current row and coord is my current column.
This doesn't match your example. Suppose you are in the upper left corner. Your row is coord and your cell is coord. It doesn't make sense to talk about the column alone since you can't reference it alone. (I'm harping on this because I think it is easier to understand as I stated it.)
Now what cell do you want to end up in when you move diagonally? What do you need to coord[x][y] to make that happen?