GetValueAt(Int a, int b) 其中 returns int
GetValueAt(Int a, int b) which returns int
我有地图,它是数组[][],我有一个方法
public int[][] getMap(){
int [][] array = new int[this.size][this.size];
for(int i=0;i<this.map.length;i++)
{
for(int j=0;j<this.map[i].length;j++)
{
array[i][j]=map[j][i];
}
}
return array;
}
现在我需要重写上面的代码
public int getValueAt(int a, int b){}
我不太明白你想达到什么目的,但我认为你想这样做:
public int getValueAt(int a, int b){
return this.map[a][b]
}
那么您可以使用如下方法:
public int[][] getTransformedCopy() {
int[][] array = new int[this.map.length][this.map[0].length]
for(int i = 0; i < this.map.length; i++) {
for(int j = 0; j < this.map[0].length; j++) {
array[i][j] = getValueAt(j, i);
}
}
return array;
}
我有地图,它是数组[][],我有一个方法
public int[][] getMap(){
int [][] array = new int[this.size][this.size];
for(int i=0;i<this.map.length;i++)
{
for(int j=0;j<this.map[i].length;j++)
{
array[i][j]=map[j][i];
}
}
return array;
}
现在我需要重写上面的代码
public int getValueAt(int a, int b){}
我不太明白你想达到什么目的,但我认为你想这样做:
public int getValueAt(int a, int b){
return this.map[a][b]
}
那么您可以使用如下方法:
public int[][] getTransformedCopy() {
int[][] array = new int[this.map.length][this.map[0].length]
for(int i = 0; i < this.map.length; i++) {
for(int j = 0; j < this.map[0].length; j++) {
array[i][j] = getValueAt(j, i);
}
}
return array;
}