Here's my code. Here PQRST should be the output but R is not printed. I don't understand why ?
class Validator{
public int[] studentId = { 101, 102, 103 };
public void validateStudent(int id) {
try {
for (int index = 0; index <= studentId.length; index++) {
if (id == studentId[index])
System.out.println("P");
}
} finally {
System.out.println("Q");
}
}
}
public class Tester {
public static void main(String[] args) {
Validator validator = new Validator();
try {
validator.validateStudent(101);
System.out.print("R");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("S");
} finally {
System.out.println("T");
}
}
}