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 atmain. - Core types:
int,double,boolean,String. - Every statement ends with a semicolon; blocks are grouped with
{ }. - Java code is compiled with
javacinto bytecode, then run on the JVM withjava.
💡 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.
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)
Free self-study lesson — no certificate. For the full instructor-led program, see registration options.