Java Bootcamp – Workbooks and Challenges
)}

Workbook 13.6

From the Java Bootcamp Resources, launch starter.

starter.png

Task 1

List<String> names = Arrays.asList("Alice", "Bob", "Charlie", "Dave");

1. map: transform each name into this greeting "Hello, " + name + "!".

2. forEach: print every greeting in the stream.

>>: Hello, Alice!
>>: Hello, Bob!
>>: Hello, Charlie!
>>: Hello, Dave!

Task 2

List<String> usernames = Arrays.asList("sparklingunicorn", "galactic_goddess", "neon_ninja", "purplepixiedust");

1. filter: keep the username that matches neon_ninja.

2. findFirst().orElse(null): return the first element in the stream.

>>: Found you: neon_ninja

Task 3

List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);

1. filter: keep the numbers that are even.

2. count(): count the number of elements in the stream.

>>: There are 3 even numbers in this list

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.