以下代码有两个错误...一个在倒数第三行,另一个在最后一行。这两行代码都包含如下错误消息:"The method put(JSONObject) is undefined for the type JSONArray." 这是什么意思,怎样可以修复这个问题?
studentJSONArray.put(studentJSONObject);//这是倒数第三行
courseJSONArray.put(courseJSONObject);//这是最后一行
studentJSONArray.put(studentJSONObject);//这是倒数第三行
courseJSONArray.put(courseJSONObject);//这是最后一行
JSONArray courseJSONArray = new JSONArray();
for(int c = 0; c < 40; c++) {
JSONObject courseJSONObject = new JSONObject();
courseJSONObject.put("course name", course.getName());
courseJSONObject.put("course teacher", course.getTeacher());
JSONArray studentJSONArray = new JSONArray();
for(int s = 0; s < 50; s++) {
JSONObject studentJSONObject = new JSONObject();
studentJSONObject.put("student name", course.student.getName());
studentJSONObject.put("student id", course.student.getid());
studentJSONObject.put("student final grade", course.student.getfinalgrade());
JSONArray assignmentJSONArray = new JSONArray();
for(int a = 0; a < 100; a++) {
JSONObject assignmentJSONObject = new JSONObject();
assignmentJSONObject.put("assignment name", getAssignmentName());
assignmentJSONObject.put("category", getAssignmentCategory());
assignmentJSONObject.put("date", getAssignmentDate());
assignmentJSONObject.put("grade", course.student.getAssignmentGrade());
assignmentJSONArray.put( assignmentJSONObject );
}
studentJSONObject.put( "assignments", assignmentJSONArray );
studentJSONArray.put( studentJSONObject );
}
courseJSONObject.put( "students", studentJSONArray );
courseJSONArray.put( courseJSONObject );
}