Workbook 13.3
From the Java Bootcamp Resources
, launch starter.
Task 1
Use forEach
to iterate the HashMap
and print the following message.
System.out.println(sku + "\t" + item.getPrice() + "\t" + item.getName())
Consider that it will rely on a BiConsumer
to perform its task.
Functional Interface | Example |
---|---|
Consumer | x -> { code } |
Predicate | x -> { return boolean } |
Function | x -> { return value } |
BiConsumer | (x, y) -> { code } |
Comparator | (x, y) -> { return int } |
BinaryOperator | (x, y) -> { return value (same type) } |
Expected Output
SKU Price Item
DOFO-008 10.0 Super Doo-dad
THNG-003 2.99 Thingamajig
WIDG-005 6.99 Super Widget
GADG-006 8.99 Super Gadget
THNG-007 15.0 Super Thingamajig
WIDG-001 3.99 Widget
GADG-002 5.99 Gadget
DBOO-004 4.99 Doo-dad
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.