Here's a familiar feeling. You want to test one small thing in Java — maybe how String.substring() behaves, or whether a regex pattern matches. So you create a file, write a class, add a main method, type System.out.println, compile, run. All that ceremony for a one-line answer.

JShell does away with the ceremony. It's a read-eval-print loop (REPL) that ships with the JDK since Java 9. You type Java code, press Enter, and see the result immediately. No class, no main method, no compile step. Think of it as a calculator for Java.

Starting JShell

Open a terminal and type:

jshell