public Student search(int find) { for(Student i: StudentBody) { if(i.studentID == find) return i; else{ return null; } } }
The compiler throws this error: StudentBody.java:50: missing return statement
Posted 09 January 2010 - 08:48 AM
public Student search(int find) { for(Student i: StudentBody) { if(i.studentID == find) return i; else{ return null; } } }
Posted 09 January 2010 - 08:50 AM
for(Student i: StudentBody) { if(i.studentID == find) return i; else{ return null; } } return null; // return statement after the loop in case the loop never enters
Posted 09 January 2010 - 08:54 AM
chili5, on 9 Jan, 2010 - 07:50 AM, said:
for(Student i: StudentBody) { if(i.studentID == find) return i; else{ return null; } } return null; // return statement after the loop in case the loop never enters
Posted 09 January 2010 - 08:56 AM
public Student search(int find) { for(Student i: StudentBody) { if(i.studentID == find) return i; else{ return null; } } return null; }
Posted 09 January 2010 - 08:57 AM
Posted 09 January 2010 - 09:00 AM
Dogstopper, on 9 Jan, 2010 - 07:57 AM, said:
Posted 09 January 2010 - 09:03 AM
public Student search(int find) { for(Student i: StudentBody) { if(i.studentID == find) return i; else{ return null; } } return null; }