To make life easier when testing simple Java code snippets, I've embedded a Java REPL in a page. Just follow the link above to the Java REPL. Also since Java 9, you can just use Java's built in REPL by typing 'jshell' from the command line.
Type the following command in the REPL.
and then press enter. You will see the following.
java> System.out.println("Hello World!");
That's all there is to it! You've written your first Java code.