如何找到存储在 ArrayList 中的 int 的索引?
public static void thisClass(int max, int[] queue1, ArrayList<ArrayList<Integer>> aList) {
int[] anArr = Arrays.copyOf(queue1, queue1.length);
Arrays.sort(anArr);
... //sorts ints into groups (ArrayList of ArrayLists)
}
int n = 0;
for (ArrayList<Integer> t : newList) {
String itemS = "";
int total = 0;
for (int index : t) {
int value = index; //isn't returning index of arrayList - its returning the value
if (!itemS.isEmpty()) {
itemS += ", ";
}
itemS += index + ":" + value; //want it to output "element Position : element Value
total += value;
}
}
}