Skip Top Navigation Bar

The Java Playground

var version = "Java 24"; System.out.println("👋 Hello, " + version);

Playing with Java in the Java Playground

The following activities are meant to be used with the Java Playground to help you discover how certain features work without the heavy lift of creating an entire program. The Java Playground is great for developers, teachers, and students as they experiment with code snippets before integrating them into larger programs.

Experiment with Arithmetic Basics

Sometimes you just want a tool that you can try a little code out in and see what it does. As you tweak and change it, you learn more and more about what it means and how it works. Students can also benefit from this explorative way to learn programming.

When I used to teach students the arithmetic operators - +, -, *, /, and % - I would provide them with some code to try out. They were supposed to first predict the result of the code segment and then try it out on their computer. Most would get the addition and subtraction expressions correct, but when it came to integer division or modulus, the results weren't what they expected. This allowed them an opportunity to modify their code to see if they could figure out what the operator actually did or why it didn't behave as they originally expected.

The Java Playground is a great tool to use for this type of hands-on exploration. We've put together a short activity that leverages the Java Playground in this Full Activity.

If, Ternary, and Switch statements

Experiment with the difference between writing an if statement and a ternary conditional expression in your program code. This set of 4 practice questions ask students to write solutions as both if statements and ternary conditional operator expressions.

Full Activity

Exploring the Use of var with the Java Playground

The introduction of var is meant to reduce the syntax when the type of a variable can be inferred.

In this activity, we will explore the different ways var can and cannot be used. This activity will leverage the Java Playground to allow for real-time feedback on statements.

Full Activity