ArrayList<Integer> weightage = new ArrayList<Integer>();
ArrayList<ArrayList<Integer>> details = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> cids = new ArrayList<Integer>();
ArrayList<Integer> chapcount = new ArrayList<Integer>();
details = getChapterWeightage(subjectId);
cids = details.get(0);
weightage.clear();
weightage = details.get(1);
int tot = 0;
for (int e = 0; e < weightage.size(); e++) {
double temp = weightage.get(e) * questionCount;
double count = temp / 100;
int fcount = (int) count;
String str = "" + count;
int in = str.indexOf(".");
str = str.substring(in + 1, in + 2);
int il = Integer.parseInt(str);
if (il >= 5) {
fcount++;
}
chapcount.add(fcount);
tot += fcount;
}
int diff = questionCount - tot;
if (diff > 0) {
int change = chapcount.get(chapcount.size() - 1);
change += diff;
chapcount.set(chapcount.size() - 1, change);
} else if (diff < 0) {
int ind = 0;
ArrayList<Integer> asas = new ArrayList<Integer>();
for (int x = 0; x < chapcount.size(); x++) {
asas.add(x);
}
Collections.shuffle(asas);
while (diff != 0) {
int change = chapcount.get(asas.get(ind));
if (change > 1) {
change = change - 1;
chapcount.set(asas.get(ind), change);
diff++;
}
ind++;
}
}
有一些阵列列表。所有ArrayList最初显示34个值。 如果我给出问题计数20,则会出现此异常。 如果我给问题计数2,那么它可以正常工作。 我必须展示物理试卷。 我也尝试过调试。
if( weightage!=null && weightage!=0)
{
weightage.remove(e);
}
I have tried above code but its not working.