Hello World
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Compile and run:

javac Main.java
java Main

This is the standard Java entry point: the main method runs first, and System.out.println prints to the console.

Variables
String name = "Dan";
int count = 1;
boolean active = true;

These are a few common Java types. Java keeps types explicit, so the declaration tells you exactly what each value holds.

Methods
static String greet(String name) {
    return "Hello, " + name + "!";
}

This is a small static method that takes one input and returns one computed string.