【发布时间】:2016-04-05 06:27:51
【问题描述】:
我正在完成我的课程作业并想出了这种情况。这是我的代码。
public static ArrayList<Student> checkPresent(String unitID, String week){
int present = 0;
ArrayList<Student> studentDetails = Student.getStudentDetails();
ArrayList<AttendanceLog> pickedList = AttendanceLog.pickFromAttendanceLog(unitID, week);
for(Student student : studentDetails){
student.setPresent("N");
for(AttendanceLog attendance : pickedList){
if(student.getStudentNo().equals(attendance.getStudentID())){
student.setPresent("Y");
present++;
}
}
}
return studentDetails;
}
我只返回了ArrayList,但我也想得到整数值present。可能吗?或者我怎样才能获取 int 值?
【问题讨论】:
-
可以将arraylist和integer封装在一个类中并返回其对象
标签: java arraylist methods return