到目前为止我有这段代码,它打印了值,但我似乎想不出一种方法来获取位置..
public static ArrayList defineSeq(){
for(int i=0; i<sparseRix.length; i++){
for(int j=0; j<sparseRix.length; j++){
int value =sparseRix[i][j];
int postion // What do i do here to get the postion
System.out.println("Value is " +value +"position" is +position);
}
}
return arrayList;
}
最佳答案
i
和 j
一起就是您的位置。要么使用数组返回它,要么使用原始数组的宽度生成一个值,如i*width + j
。
关于java - 您好,我如何找到数组中的值和位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15350766/