为什么第一个工作而另一个不工作?
for (int v=0; v< student1.size();v++) {
readLine = student1.get(v);
if (readLine.contains(sbB)){
while(!(readLine1.contains(sbA) || readLine1.contains(sbC) || readLine1.contains(sbD) )){
readLine1 = student1.get(ii);
if(readLine1.contains("Homework ")){
String[] tokens = readLine1.split(": "); st1marksHwB.add(tokens[1]);summHw = summHw + Integer.parseInt(tokens[1]);}
if (readLine1.contains("Exam ")){
String[] tokens = readLine1.split(": "); st1marksExB.add(tokens[1]);summEx = summEx + Integer.parseInt(tokens[1]);;}
ii++;}}}
double avSt1B = summHw*0.2 + summEx*0.8; summHw=0;summEx=0;
//Stundent 1 Subject C---------------------------------------------------
for (int v=0; v< student1.size();v++) {
readLine = student1.get(v);
if (readLine.contains(sbC)){
while(!(readLine1.contains(sbA) || readLine1.contains(sbB) || readLine1.contains(sbD) )){
readLine1 = student1.get(ii);
if(readLine1.contains("Homework ")){
String[] tokens = readLine1.split(": "); st1marksHwC.add(tokens[1]);summHw = summHw + Integer.parseInt(tokens[1]);}
if (readLine1.contains("Exam ")){
String[] tokens = readLine1.split(": "); st1marksExC.add(tokens[1]);summEx = summEx + Integer.parseInt(tokens[1]);;}
ii++;}}}
double avSt1C = summHw*0.2 + summEx*0.8; summHw=0;summEx=0;
答案 0 :(得分:1)
这是因为您使用ii
在第一个for循环中增加了ii++
的值。
然后将ii
的最后一个增加值传递给第二个for循环。