I am fetching a course object by its course run id. Below is my code that works perfectly ok.
public static CourseVO getBlackboardCourseObjectByCourseRunID(String RunID){
CourseVO[] courseVOList = null;
try {
courseVOList = BlackboardCoursesDAO.getAllBlackBoardCourse();
} catch (RemoteException e) {
// TODO Auto-generated catch block
throw new RuntimeException("Not able to fetch blackboard courses");
}
CourseVO courseVO = new CourseVO();
int length=courseVOList.length;
System.out.println("length : "+length);
int i=0;
courseVO = courseVOList[i];
while(!courseVO.getId().equals(RunID) && i<length){
courseVO = courseVOList[i];
//System.out.println("in while loop ");
i++;
}
return courseVO;
}
But it troubles when I try to fetch this object in a loop. If anyone can provide some better code, it will be great help.
Thanks.