在java.awt中使用Point类查找二维数组的点,可以按照以下步骤进行:
import java.awt.Point;
int[][] array = {
{1, 2},
{3, 4},
{5, 6}
};
Point targetPoint = new Point(3, 4);
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
if (array[i][j] == targetPoint.x && array[i][j+1] == targetPoint.y) {
System.out.println("目标点的坐标为:" + targetPoint.x + ", " + targetPoint.y);
return;
}
}
}
import java.awt.Point;
public class Main {
public static void main(String[] args) {
int[][] array = {
{1, 2},
{3, 4},
{5, 6}
};
Point targetPoint = new Point(3, 4);
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
if (array[i][j] == targetPoint.x && array[i][j+1] == targetPoint.y) {
System.out.println("目标点的坐标为:" + targetPoint.x + ", " + targetPoint.y);
return;
}
}
}
System.out.println("未找到目标点!");
}
}
这样,就可以在java.awt中使用Point类查找二维数组的点。请注意,以上示例代码仅为演示如何使用Point类进行查找,实际应用中可能需要根据具体需求进行适当修改。
领取专属 10元无门槛券
手把手带您无忧上云