public class BookRental { String id; String customerName; ... } public class BookRentals { private Vector rentals; public String getCustomerName(String rentalId) {  for (int i = 0; i < rentals.size(); i++) { BookRental rental = (BookRental) rentals.elementAt(i); if (rental.getId().equals(rentalId)) { return rental.getCustomerName(); } } throw new RentalNotFoundException(); } } public class RentalNotFoundException extends Exception { ... }