我有这个类,它在首选输入后显示数组的值:
class MyArrayList {
private int [] myArray;
private int size;
public MyArrayList (int value, int seed, int inc){
myArray = new int [value];
size = value;
for (int i = 0; i < size; i++) {
myArray [i] = seed;
seed += inc;
}
}
}
public class JavaApp1 {
public static void main(String[] args) {
MyArrayList a = new MyArrayList(5, 2, 1);
a.printList();
}
}
这个程序显示输出: 2 3 4 5 6 现在我想找到 4 的索引,所以这将是 2 但我怎样才能将它放入程序中?