I have an array in the form of ‘int[][]‘ that represents the co-ordinates of a small grid. Each co-ordinate has been assigned its own value. eg array[0][4] = 28……
I have two questions. Firstly, how do I iterate through all the stored values. Secondly, I want to be able to input a value and have its specific co-ordinates in the grid returned. What would be the best way to approach this?
Thank you for any help!
You can iterate with either for loops or enhanced for loops:
or
The first version would be the easiest solution to the ‘find the co-ordinates’ question – just check whether the value in the inner loop is correct.