为什么以下不断返回越界错误?

时间:2018-03-09 05:03:14

标签: java arraylist

请帮助我弄清楚为什么这会导致越界错误。我试着单独循环跟踪AdminDecisions

String returnProfile() {

    String uniPicksString ="";
    String studentInfo = null;


    //for(int i = 0; i<ApplicantArray.size(); i++) {
        studentInfo =FAMILYNAME+ ", " + "average = " + AVERAGE + " ";
            for (int j = 0; j<CHOICES.size(); j++) {            
                if(j<CHOICES.size() - 1) {
                    uniPicksString = uniPicksString + CHOICES.get(j)+ ": " + " admin decision, " ;
                }else {
                    uniPicksString = uniPicksString + CHOICES.get(j)+ ": " + " admin decision"  + "\n";
            }   
        }   
    //}
    return studentInfo  + uniPicksString + "\n";
}

以下代码显示了所需的输出,但我不能将其作为字符串

返回
 String printProof() {
 // System.out.println("from inside the student class");
    String temp=null;
    d = new ArrayList<String>();
    for(int j = 0 ; j<1; j++) {
        System.out.print("\n >>printProof<<  " + FAMILYNAME+", " + "average = " + AVERAGE + " ");
        for (int i = 0; i<AdminDecision.size(); i++) {
             //System.out.println(AdminDecision.get(i));    
             //temp = CHOICES.get(i)+ ": " + AdminDecision.get(i) + ", ";
            if(i<CHOICES.size() - 1) {
                temp = CHOICES.get(i)+ ": " + AdminDecision.get(i) + ", ";
            }else {
                temp = CHOICES.get(i)+ ": " + AdminDecision.get(i) + "\n";
            }
            System.out.print(temp + " ");
            d.add(AdminDecision.get(i));
        }
    }
    return temp + "\n";
}

0 个答案:

没有答案