Introduction to Java
Java is one of the world's most widely used programming languages. Understanding what it is, how it runs, and why it dominates the South African job market is the foundation of this course.
What is Java?
Java is a general-purpose, object-oriented programming language created by James Gosling at Sun Microsystems, first released in 1995. Its central principle is write once, run anywhere: Java source code compiles to bytecode, which the Java Virtual Machine (JVM) then executes on any operating system. The same compiled file runs on Windows, Linux, and macOS without modification.
This portability is why Java became dominant in enterprise software. A banking application written and tested on a developer's laptop deploys unchanged to a Linux server in a data centre. No recompilation. No platform-specific builds.
Why Java Dominates South African ICT
Java consistently tops South African IT job listings. The reason is structural: the banking and financial services sector — one of Africa's most sophisticated — runs primarily on Java. Absa, Standard Bank, FNB, Nedbank, and Capitec all rely on Java backends for core transaction processing, online banking, and data pipelines. Government agencies, insurers, and major retailers use Java enterprise frameworks for internal systems. The Android mobile platform, which powers the majority of South African smartphones, also uses Java and its sibling Kotlin.
Learning Java is not just learning a language — it instills the habits (type discipline, OOP design, explicit error handling) expected of professional developers across Java, Kotlin, C#, and Scala alike.
How Java Runs: The Three-Step Model
Before writing a single line, understand this execution flow:
- You write source code in a
.javafile. javaccompiles it to bytecode in a.classfile.- The JVM executes the bytecode on your operating system.
Unlike Python (interpreted directly) or C++ (compiled to native machine code), Java sits deliberately in between: compiled for speed checking, bytecode-based for portability.
Your First Java Program
Every Java program lives inside at least one class. Execution always begins at a method with the exact signature public static void main(String[] args) — the JVM looks specifically for this:
public class Hello {
public static void main(String[] args) {
System.out.println("Sanibonani, world!");
}
}
Dissecting Every Token
public class Hello— declares a class. The filename must beHello.java— an exact case-sensitive match. One mismatch gives an immediate compile error.public static void main(String[] args)— the JVM entry point.publicmeans the JVM can call it.staticmeans no object is needed.voidmeans it returns nothing.String[] argsholds any command-line arguments you pass in.System.out.println(...)—Systemis a class in the standard library.outis its output stream.printlnprints and adds a newline. You will type this thousands of times in your career.- Curly braces
{ }— open and close every block: class body, method body, if-statement, loop. Every opening brace needs a matching closing brace. - Semicolons
;— terminate every statement. Forgetting one is the single most common beginner compile error.
Printing Output
System.out.println("Hello"); // prints text + newline
System.out.print("Hello, "); // prints text WITHOUT newline
System.out.println("Thandi!"); // same line: Hello, Thandi!
System.out.println(2 + 2); // prints 4
System.out.println("2 + 2 = " + (2 + 2)); // prints 2 + 2 = 4
Comments
Comments are ignored entirely by the compiler. Develop the habit of commenting your code — it demonstrates professionalism and makes your code readable to colleagues and future you.
// Single-line comment — everything after // on this line is ignored
/*
Multi-line comment.
Use for longer explanations or
temporarily disabling a block of code.
*/
/**
* Javadoc comment — tools convert these into HTML API documentation.
* Professional libraries like Spring use these extensively.
*/
public class Demo { }
Practice Task
Your Turn
Write a program that prints five lines: your full name, your city, your reason for learning to code, the current year, and a greeting to your future employer. Compile it with javac and run it with java.
Common Mistakes
- File name must exactly match the class name — case-sensitive.
- Forgetting the semicolon at the end of a statement.
system.out.println— Java is fully case-sensitive.- Installing only the JRE — you need the JDK to compile with
javac. - Writing executable code outside a method — all statements must be inside a method body.
Professional Tip
Every professional Java developer started exactly here. The Hello World program proves your environment works, your syntax is correct, and you can produce output — that is the bedrock of everything else.
Mini Quiz
What does the JVM do with compiled Java bytecode?