/** * Applies an action to each value in the array. * <p> * This is used to perform an action on the contents of this array. * The action receives both the index and the value. * For example, the action could print out the array. * <pre> * base.forEach((index, value) -> System.out.println(index + ": " + value)); * </pre> * <p> * This instance is immutable and unaffected by this method. * * @param action the action to be applied */ public void forEach(IntIntConsumer action) { for (int i = 0; i < array.length; i++) { action.accept(i, array[i]); } }
void processSale(Item item, Customer customer, IntIntConsumer func) { ... func.accept(item.getAmount(), customer.getAccount()); ... }