Reputation: 55
Let's say I have two arrays (one being one dimension and the next being 2d)
int[] attack = {0,1};
int[][] coords = {{0,1,2,3,4},{0,1,2,3,4}};
And I want to search for attack[0] in only the first dimension of coords?
How would I go about doing this?
Upvotes: 0
Views: 110
Reputation: 5138
Perhaps this is what you mean?
for(int[] a : coords) {
if(a[0] == attack[0]) {
// do something
}
}
Upvotes: 1
Reputation: 31
for(int element : coords[0]) {
if(element == attack[0]) {
// do stuff
}
}
Upvotes: 0