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.

All topics in Java Beginner

  1. Introduction to Programming & Java
  2. Your First Java Program
  3. Variables — Your Data Containers
  4. Data Types — Kinds of Values
  5. Operators & Expressions
  6. Conditional Statements
  7. Loops & Iterations
  8. Methods
  9. Arrays & Lists
  10. Objects & Classes
  11. Strings — Working with Text
  12. Exception Handling
  13. Mini-Projects & Practice