Java Bootcamp – Workbooks and Challenges
)}

Workbook 13.1

From the Java Bootcamp Resources, launch starter.

starter.png

Task 1

Use forEach to iterate the ArrayList and print the following messages.

System.out.println("Date: " + p.getDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))); System.out.println("Amount: " + p.getAmount()); System.out.println("---");

Consider that forEach relies on a Consumer to perform its task.

Functional InterfaceExample
Consumerx -> { code }
Predicatex -> { return boolean }
Functionx -> { return value }
BiConsumer(x, y) -> { code }
Comparator(x, y) -> { return int }
BinaryOperator(x, y) -> { return value (same type) }

Expected Output

Date: 01/01/2020
Amount: 100.0
---
Date: 15/02/2020
Amount: 200.0
---
Date: 30/03/2020
Amount: 300.0
---
Date: 01/04/2020
Amount: 50.0
---
Date: 15/05/2020
Amount: 75.0
---
Date: 30/06/2020
Amount: 100.0
---

Associated Course: The Complete Java Development Bootcamp
Related Course: The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary
4.7
43 students
5

91%
4

2%
3

0%
2

0%
1

7%
Written Reviews
There are no written reviews yet.