Training

Practice Java by predicting the exact output.

Read the snippet, think through the mutations and branches, then write what Java would print line by line.

Advertisement

Challenges

Choose an exercise to start practicing.

Collections

Iterating an ArrayList

Beginner

Predict exactly what the console prints after the loop runs.

Maps

Keeping insertion order

Intermediate

Fill in the two lines that this LinkedHashMap iteration will print.

Strings

Tweaking text with StringBuilder

Beginner

Type the exact line printed, including spaces and capitalization.

Control Flow

Flow control with break/continue

Intermediate

What single number reaches System.out.println at the end?

Streams

Chaining Stream operations

Intermediate

Write the exact string printed when this stream pipeline executes.

Optional

Optional filtering

Beginner

Predict the two lines printed when working with Optional.filter + orElseGet.

Collections

Deque pushes vs polls

Intermediate

Determine the three lines printed after mixing add, push, and poll operations.

Maps

Merging HashMap values

Advanced

Observe how Map.merge mutates entries; type the two numbers printed.