abc123
abc123

Reputation: 3

How to store 2D Array coordinates in a list in java

Question is kind of hard to ask. I'll try my best to explain it.

I have a 2D array that is a grid. This grid has its contents filled with 0 and 1.

I want to store in a list the coordinates of the array that only have 0. How would you do that?

For example: the coordinate location 2, 3 has the value of 0. How should one go about storing the 2, 3?

Upvotes: 0

Views: 6714

Answers (1)

duffymo
duffymo

Reputation: 308733

Create a Point class that has coordinates (x,y) and the value 0 or 1. Store a List<Point> and you're all set.

Upvotes: 5

Related Questions