Featured resource
2026 Tech Forecast
2026 Tech Forecast

1,500+ tech insiders, business leaders, and Pluralsight Authors share their predictions on what’s shifting fastest and how to stay ahead.

Download the forecast
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Core Tech
Labs

Java Base Camp: Interactive Console

The base camp runs a small console kiosk where guides check hikers in before a trek. The kiosk needs to clean up messy trail codes typed at registration, print clear check-in confirmations (and route problems to an error stream so the guide's terminal logs stay readable), ask each hiker how many nights they plan to camp, and start up with the camp's name and capacity supplied as launch arguments so the same jar can run for any camp. You will build each of these pieces, then finish with a tiny standalone digest tool written in Java's newest compact source style.

Lab platform
Lab Info
Level
Beginner
Last updated
Dec 02, 2026
Duration
45m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Step 1: Arrive at the base camp

    Java Base Camp: Interactive Console

    The base camp runs guided treks out of a single console kiosk, and right now that kiosk is half-built. Guides use it to register hikers before they set out, and it has four jobs: clean up trail codes that hikers scribble on registration slips, print clear check-in confirmations without burying them in error noise, ask each hiker how many nights they're camping, and start up already knowing which camp it's running at. You'll finish each of these pieces in order, then wire up a tiny closing-digest tool using Java's newest compact source syntax. ## Where you'll work

    All of your edits live under src/main/java/lab/:

    • TrailCode.java -- normalizes messy trail codes typed at the kiosk.
    • ConsoleMessages.java -- builds and routes check-in and alert text.
    • CheckIn.java -- reads a hiker's arrival note and stay length from the terminal.
    • BaseCampConsole.java -- reads the camp's name and capacity from launch arguments.
    • DailyDigest.java -- a standalone compact-source program for the closing digest.

    Each file already compiles with // TODO stubs marking exactly what you'll fill in. Nothing else in the project needs to change. ## How the checks work

    Every task you complete is checked by running the project's test suite with mvn --batch-mode --quiet test. Each task maps to one test method, so you can tell exactly which piece of behavior is still missing. Work through the steps in order -- later files assume the earlier ones already behave correctly. When you're ready, head into Step 2 and start with the trail codes.

    info> If you get stuck, you can refer to the provided solution code for each task, available in the solution folder.

  2. Challenge

    Step 2: Clean up hiker trail codes

    Step 2: Clean up hiker trail codes

    Every hiker checking in at the base camp hands over a trail code scrawled on a registration slip -- sometimes with spaces, sometimes with dashes, sometimes in lowercase. Before the kiosk can match that code against anything, it needs two things: a quick way to describe the raw code as the hiker wrote it, and a way to normalize it into one consistent format for comparison. You'll build both in TrailCode.java, using String's length() and replace() methods -- the same tools you'll lean on throughout this lab whenever raw input needs shaping into something the rest of the app can trust. With describeCode reporting the raw code and its length, the next problem is that the same trail code can arrive in wildly different shapes: "tc 104", "TC-104", and "tc104" should all be treated as one code. String methods chain naturally for this -- each .replace(...) call returns a new string, so you can pipe the result straight into the next call and finish with .toUpperCase() to settle case once and for all. normalizeCode builds that pipeline, while describeCode keeps reporting on the untouched original -- the paper log always needs the code exactly as the hiker wrote it.

  3. Challenge

    Step 3: Announce check-ins and alerts

    Step 3: Announce check-ins and alerts

    A hiker with a clean trail code still needs to hear back from the kiosk. Right now ConsoleMessages.java has the shape of that conversation but none of the words or wiring: it needs to assemble a confirmation message, print that confirmation where the guide can see it, and push low-supply warnings somewhere they won't get lost in the normal check-in log. Java gives you string concatenation and escape sequences to build the text, and two separate streams -- System.out and System.err -- to keep routine confirmations apart from things that need attention. ## Building multi-line text with + and escape sequences

    The + operator concatenates strings, and escape sequences like \n (newline) and \t (tab) let you shape plain text into something readable in a terminal without any special formatting library. "a" + "\n\t" + "b" produces a, a newline, a tab, then b. buildCheckInMessage needs exactly this kind of layout: a header line, then the hiker's name and trail code each on their own indented line. ## Standard output: where confirmations belong

    Building a string and printing it are separate jobs -- buildCheckInMessage hands back text, and something else has to decide where that text goes. System.out.println writes to standard output, the stream a terminal shows by default and the one guides will actually be watching as hikers check in. printCheckIn just needs to forward the message it's given straight to that stream. ## Standard error: where alerts belong

    Standard output is for the expected, routine flow -- confirmations, one after another. Low-supply warnings are a different kind of message: they need to stand out from that flow, and many log setups filter or highlight System.err separately from System.out for exactly this reason. printLowSupplyAlert builds its own short, labeled string and sends it through System.err.println instead, so a guide scanning error logs won't have to dig through normal check-in traffic to find it.

  4. Challenge

    Step 4: Interview hikers at the kiosk

    So far the kiosk has cleaned up trail codes and printed status messages to the right stream, but it has never actually listened to a hiker. A check-in kiosk that only talks isn't a kiosk -- it needs to read what's typed at the terminal. Java's java.util.Scanner wraps an input source (here, System.in) and gives you methods that pull typed text off it a line, a word, or a number at a time. The most basic of these is nextLine(), which blocks until the hiker presses Enter and then hands back everything they typed on that line, unmodified. You'll use it in CheckIn.java to capture the free-text note a hiker gives about their arrival. An arrival note is free text, so returning it untouched was the right call. The next thing the kiosk needs from the hiker is a number -- how many nights they plan to camp -- and numbers typed at a terminal always arrive as text too. Scanner has no built-in nextInt()-then-forget-the-line-ending trick that's safe to mix with nextLine(), so the reliable pattern is: read the line as a string, trim() it in case the hiker left a stray space, then hand it to Integer.parseInt(...) to get a real int. Skip the trim and a trailing space turns a perfectly good "3" into a NumberFormatException at parse time. You now have two pieces sitting in the caller's hands: the raw arrival note and a parsed int for nights. The kiosk's job is to turn those into one line a guide can read at a glance. String concatenation with + handles this without any extra conversion -- when Java sees an int on one side of a + with a String on the other, it converts the number to its text form automatically, so you can build the whole summary in a single expression.

  5. Challenge

    Step 5: Launch the camp and log the day

    The kiosk has cleaned up trail codes, printed status and alerts to the right streams, and read a hiker's answer from the keyboard. The last piece it's missing is knowing which camp it's running at and how big that camp is -- neither of those should be hard-coded, because the same jar has to work for any base camp. Java programs get this kind of launch-time configuration through the String[] args array that's handed to main: whatever text follows the program's name on the command line (or in an IDE's "program arguments" field) shows up there, in order, as plain strings. args[0] is the first argument, args[1] is the second, and so on -- there is no built-in name lookup, just position. Because the array is only as long as what the launcher supplied, args.length tells you how many values actually arrived, and indexing past it throws an ArrayIndexOutOfBoundsException. Open BaseCampConsole.java. The launch arguments for this kiosk are always the camp's name followed by its capacity, so reading the name is just reading args[0]. Capacity arrives the same way, but as text -- args[1] is the string "40", not the number 40. Integer.parseInt converts a numeric string into an int so it can be used in arithmetic or printed as a number rather than concatenated as a character sequence. Before reading either value, the banner should check args.length so a kiosk launched without a capacity prints a clear usage message rather than crashing. The startup banner needs both pieces of information stitched into one line the guide sees the moment the console starts. For the final piece, step outside the console entirely. DailyDigest.java is a tiny standalone program that prints one closing line at the end of the day, and it's written in Java's newest compact source form. Ordinarily every Java program needs a public class declaration and a main method stamped public static void main(String[] args), even when the program never uses args or needs more than one class. Compact source files let a file with a single top-level type skip the public class Name { ... } wrapper and the String[] args parameter, and they pull in java.lang.IO's helpers automatically, so IO.println(...) is available without an import or System.out. The starter already gives you this shape; your job is just to fill in the one line the digest prints.

  6. Challenge

    Step 6: Run the application

    Every task is done, and each one was graded the moment you completed it. What you have not done yet is watch the whole application run at once -- which is the only place the pieces you wrote separately become a single working program.

    Start the application

    Open the Terminal tab and run:

    mvn --batch-mode --quiet compile && java -cp target/classes lab.Main
    

    The program runs in the terminal and prints its output there. Every behaviour it shows is code you wrote in the previous steps, so read the output against what each task asked for -- that is the whole lab, working as one program. ### Run the checks yourself

    The lab ran each task's test for you as you went, but they are ordinary tests and you can run them whenever you like. The whole suite:

    mvn --batch-mode --quiet test
    

    Or one task at a time:

    bash runTest.sh task_2_1
    

    Each failure names the task it belongs to, so the output tells you which step to go back to rather than which line to stare at. Two things worth trying before you finish: break something on purpose and watch the matching check fail, then put it back. Knowing what a failure looks like is worth as much as knowing what a pass looks like, and it costs you nothing here.

    When you are done, everything you wrote is still in the editor tabs -- the lab is yours to keep reading.

About the author

Pluralsight’s AI authoring technology is designed to accelerate the creation of hands-on, technical learning experiences. Serving as a first-pass content generator, it produces structured lab drafts aligned to learning objectives defined by Pluralsight’s Curriculum team. Each lab is then enhanced by our Content team, who configure the environments, refine instructions, and conduct rigorous technical and quality reviews. The result is a collaboration between artificial intelligence and human expertise, where AI supports scale and efficiency, and Pluralsight experts ensure accuracy, relevance, and instructional quality, helping learners build practical skills with confidence.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight