YOu've defined the function
map
as returning an integer value - so that is all it can pass back to the caller when it finishes. If you want it to return more data, you need to change the way it's declared and return a different datatype.
Think of like this: you go to the cinema and then want $15 per person. You hand them a $20 note, and they return $5 and let you in to see the movie.
That's a fucntion returning an integer:
public int pay movie(int payment, int persons) {
return payment - (persons * 15);
}
But if you go to the supermarket, you expect the shop to let you leave with a bag of groceries and your change - and that doesn't fit in an integer value at all, so you need to return a class instance that holds an array of products, and an integer change value.
If you want your
map
function to pass a grid back to what called it, then you need it to return an array:
public int[][] map() {
...
return grid;
}
And change your code that calls it to handle a different return type.