I am trying to understand the below code:
public class StudentManager {
public Student find(String studentID) throws StudentNotFoundException {
if (studentID.equals("123456")) {
return new Student();
} else {
throw new StudentNotFoundException(
"Could not find student with ID " + studentID);
}
}
}
public Student find(String studentID) throws StudentNotFoundException - is this public Student a nested class? And then we used find(String studentID) a method? Can anyone please help me interpret this code? I am following this link for understanding custom exception handling.
Update:
public class StudentTest {
public static void main(String[] args) {
StudentManager manager = new StudentManager();
try {
Student student = manager.find("0000001");
} catch (StudentNotFoundException ex) {
System.err.print(ex);
}
}
}