Java practice
You reinforce collection, stream, file and object design skills with short Java tasks that must pass ready-made tests.
Level 201 · 16 lessons · 15 practice labs
Lessons
Text and collections
- Exercise: Unicode-aware palindromes and anagrams
- Exercise: a word index from a text
- Exercise: finding the top N items efficiently
- Exercise: merging overlapping time ranges
- Short task: clean duplicate records from a staff list
Streams and objects
- Exercise: turning a loop into a stream pipeline
- Exercise: parsing lines into record objects
- Exercise: a state machine with an enum
- Exercise: a generic cache class with expiry
- Short task: an order workflow that validates state changes
Files, time and concurrency
- Exercise: size statistics for a directory tree
- Exercise: time-zone conversions with java.time
- Exercise: hashing files in parallel
- Exercise: producer and consumer with a BlockingQueue
- Short task: find missing days in rotated logs
Capstone
- Capstone: an access review report from an access list
Practice labs
- A palindrome check with Turkish letters: Write a palindrome method that ignores spaces and punctuation and uses the Turkish locale correctly for case conversion.
- Building a word index from a text: Produce with a TreeMap an index giving the sorted, duplicate-free line numbers where each word appears.
- Finding the top N items efficiently: Find the N most frequent among millions of search terms with a fixed-size priority queue without sorting everything and beat the time limit.
- Cleaning duplicates from a staff list: Deduplicate staff records that differ only in case and spaces by e-mail, keeping the first seen.
- Merging overlapping shift ranges: Merge overlapping and adjacent shift ranges and compute the total time covered.
- Finding missing days in rotated logs: Find the missing days from dates in file names, recognising compressed and double-extension names and handling month and year boundaries.
- Turning a loop into a stream pipeline: Convert a method computing a total with a nested conditional loop into a stream pipeline giving the same result.
- Parsing lines into record objects: Turn semicolon-separated measurement lines into record objects, drop bad lines through Optional and report their count.
- A generic cache class with expiry: Write a cache with key and value type parameters whose entries expire and which has a capacity limit, testable with a fake clock.
- A traffic light cycle with an enum: Define light states as an enum and write methods returning each state's duration and next state.
- Validating transitions in an order workflow: Define the allowed transitions between order states inside the enum and throw without changing state on a forbidden one.
- Writing a state machine for a vending machine: Write a vending machine covering coin insert, product select, refund and sold-out states and test that the balance never goes negative over random event sequences.
- Size statistics for a directory tree: Walk a tree with Files.walk and return the file count and total size per extension.
- Converting a meeting time between time zones: Convert a meeting time to the participants' time zones with java.time, handling times that fall on a daylight-saving change correctly.
- A producer and consumer line with a BlockingQueue: Connect two stages that produce and write file hashes with a bounded BlockingQueue, shut down cleanly with a poison pill and skip no file.
About this course
You reinforce collection, stream, file and object design skills with short Java tasks that must pass ready-made tests.
What you will learn
- Text and collections
- Streams and objects
- Files, time and concurrency
- Capstone
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.