我有一个数组(Arr)。我用值填充 points1 和 points2。
public class Arr {
float pointX;
float pointY;
boolean yesNo;
String text;
}
public Arr points1[];
public Arr points2[];
points1 = new Arr[100];
for (int i = 0; i < 100; i++) points1[i]= new Arr();
for (int j = 0; j < 100; j++) {
points1[j].pointX = getFloat;
points1[j].pointY = getFloat;
points1[j].yesNo = getBoolean;
points1[j].text = getText;
}
points2 = new Arr[100];
for (int x = 0; x < 100; x++) points2[x]= new Arr();
for (int y = 0; y < 100; y++) {
points2[y].pointX = getFloat;
points2[y].pointY = getFloat;
points2[y].yesNo = getBoolean;
points2[y].text = getText;
}
这行得通,但是,当我有五个或更多(points1,points2,points3 ...)时,我该如何制作“public Arr points[][]”?然后使用 points[0][22].pointX 或 points[1][10].text 填充并获取值?
以及如何在 PHP 中看到像 var_dump 这样的 points[][] 数组?如何列出数组?var_dump 示例:
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
}