如何存储二维数组在Java中的一个坐标列表 [英] How to store 2D Array coordinates in a list in java

查看:960
本文介绍了如何存储二维数组在Java中的一个坐标列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是一种很难问。我会尽我所能来解释它。

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

我有一个二维数组这是一个网格。该网格内积满了0和1的内容。

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

我想在一个列表存储阵列的坐标,只有有0.你会怎么做呢?

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

例如:坐标位置2,3有0人应该如何去存储值2,3

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

推荐答案

创建一个具有坐标(x,y)和值0或1存储一个类一个列表与LT;点方式> 和你所有的设置

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

这篇关于如何存储二维数组在Java中的一个坐标列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆