Ch 2 · Your First Java Program · Java
Topic 2 of 13 in Java — Complete Tutorial (Beginner) — 2 lessons.
Hello World!
Every Java program lives inside a class, and starts running from a special method called main. This structure is required — Java is strict about it. Inside main, we use System.out.println(...) to print a line of text to the screen. Notice every statement ends with a semicolon ; — in Java that is required, like a full stop at the end of a sentence.
Understanding println and print
Java gives you two main ways to display text. System.out.println(...) prints its text and then moves to a new line. System.out.print(...) prints without moving to a new line, so the next output continues on the same line. You can join text and values together with the + operator, which is perfect for building messages out of fixed words and changing values.