Skip to content

Exercise path · Java

10 Java exercises, in order

From your first line to a complete program you assembled yourself. Each exercise introduces exactly one new idea, runs in this tab, and tells you in plain language what happened.

How the path works

You never start from a blank editor. Every exercise hands you a program that already runs and asks you to change or add one thing, so the first success is minutes away and the last exercise is a program you can read top to bottom and explain. The ideas arrive in this order: output, variables, arithmetic, conditions, loops, loops and conditions, strings and formatting, lists, putting it together, a complete program.

Run is the check. There is no separate submit button: press Run, and the output is compared with what the exercise asked for. When it is not right, the feedback is a sentence about what happened — the line that differed, or what the error means — rather than a verdict. Hints come one at a time, and the answer opens only after you have run your code at least once, because reading the answer first is how you learn nothing.

Your finished exercises and the code you last had in the editor are saved in this browser, so a half-done exercise is still there tomorrow. Nothing is uploaded and there is no account.

The exercises

  1. Hello, Out LoudA banner with your own name inside it, printed by Java code that you compiled and ran yourself.New idea: System.out.println prints a line, and a Java program always starts inside a main method
  2. Name TagA bordered name-tag card with your own name across three of its lines, every one of them fed by a single line of code.New idea: A variable in Java has a fixed type, and String stores text under a reusable name
  3. Party PlannerA pizza order summary that works itself out from the guest list — slices needed, whole pizzas, and the slices that spill past them.New idea: Java splits division into two operators: / for whole groups, % for what's left over
  4. Umbrella or NotA rain report card that reads the forecast for you and signs off with a straight answer — take the umbrella, or leave it at home.New idea: if/else chooses between two outcomes, and the test inside it must itself be true or false
  5. CountdownA launch sequence that counts itself down from five, then prints a liftoff banner and a small rocket.New idea: A for loop's own three parts, not a helper function, decide how it counts
  6. The Clapping GameA count from one to twenty where every third number comes out as a clap instead, so the beat runs in a straight line down the screen.New idea: An if nested inside a for loop is decided again on every pass through the loop
  7. The ScoreboardA game scoreboard where every name, score and bar lands in the same column, with each row built from one formatted piece of text rather than pasted-together pieces.New idea: String.format drops values into fixed-width slots so columns line up
  8. Packing ListA travel packing checklist with a banner, one tick-box line for every item you add to the list, and a footer that counts them for you.New idea: ArrayList holds a growable list of values, walked with a for-each loop
  9. Rainfall WeekA seven-day rainfall chart with a row for every day, the week added up underneath it, and the wettest of the seven days picked out.New idea: A variable created above a loop carries a running value from one pass to the next
  10. The Cafe TicketA printed cafe receipt with the shop name at the top, three item rows in straight columns, a subtotal, a service charge the program works out itself, a total, and a thank-you line at the bottom.New idea: Assembling a complete program from parts you already know

After the path

The Java playground is where to build something of your own, and the Java guide sets out a learning order for everything after the basics. Everything you can practise Java with on this site is gathered on the Java practice hub. The same path also exists in Python, JavaScript, TypeScript, C++, C, C#, Go, PHP, Ruby, SQL, R and Bash & the Shell.