Java Starter · free course

Free course · Lesson 1 of 5

Java Fundamentals & Setup

In this lesson you will

  • Explain how a Java program is compiled and run
  • Write a main method that stores values in variables and prints them

Java powers everything from Android apps to enterprise banking systems, because it is strongly typed, compiled, and runs identically on any machine with a Java Virtual Machine (JVM) — "write once, run anywhere." Every value has a declared type, which catches many mistakes before the program even runs.

  • Every Java program lives inside a class, and execution starts at main.
  • Core types: int, double, boolean, String.
  • Every statement ends with a semicolon; blocks are grouped with { }.
  • Java code is compiled with javac into bytecode, then run on the JVM with java.

💡 Practical Skill: Install a current JDK (Java 21 LTS or newer) and IntelliJ IDEA. Learn to read a compiler error message line by line — Java's errors are strict but precise, and they teach you fast.

Worked exampleHello World & Variables
Java
public class Main {    public static void main(String[] args) {        String name = "Grace";        int age = 22;        String city = "Juba";         System.out.println(name + " is " + age + " years old and lives in " + city + ".");    }}

Practice exercise

Write a program that stores the prices of three items in SSP in variables and prints each one and their total on separate lines.

Key takeaways

  • javac compiles .java files to bytecode; the JVM runs it
  • Every variable has a fixed type such as int, double or String
  • A program starts in public static void main(String[] args)
In the full program Module 1: Java Setup and First Programs See how this topic is taught in depth, with practical activities and an assessment.

Free self-study lesson — no certificate. For the full instructor-led program, see registration options.