Consider once again the PaymentList class of Chap. 11. In particular here is a reminder of its getItem method that returns a particular payment given a position in the list: /** Reads the payment at...

Consider once again the PaymentList class of Chap. 11. In particular here is a reminder of its getItem method that returns a particular payment given a position in the list: /** Reads the payment at the given position in the list * @param positionIn The logical position of the payment in the list * @return Returns the payment at the given logical position in the list * or null if no payment at that logical position */ public Payment getPayment(int positionIn) { //check for valid logical position if (positionIn getTotal()) { // no object found at given position return null; } else { // take one off logical position to get ArrayList position return pList.get(positionIn - 1); } } (a) Explain the purpose of the Optional class. (b) Re-write the getPayment method using an Optional class.
Nov 15, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here