TExcelTAD
Home › Java › Java Intro

Java Introduction

Java is a general-purpose, object-oriented programming language that first appeared in 1995. Its famous promise is "write once, run anywhere": you compile your source code into bytecode, and that bytecode runs unchanged on any machine that has a Java Virtual Machine (JVM) — Windows, macOS, Linux, servers, phones and even smart cards.

Three decades later Java is still one of the most widely used languages in the world. It powers bank back-ends, online shops, big-data platforms, Android apps and countless internal business systems.

What is Java used for?

  • Web back-ends and REST APIs (Spring Boot, Jakarta EE, Quarkus)
  • Android apps (Java and its cousin Kotlin both run on Android)
  • Large enterprise systems in banking, insurance and retail
  • Big-data tools such as Apache Kafka, Hadoop and Elasticsearch
  • Desktop tools and IDEs (IntelliJ IDEA itself is written in Java)
  • Games — the original Minecraft is a Java program

Why learn Java?

Feature What it means for you
Platform independent The same compiled program runs on every JVM
Strongly, statically typed Many mistakes are caught by the compiler before the program runs
Object-oriented Code is organised into classes and objects that model real things
Automatic memory management A garbage collector frees memory you no longer use
Huge standard library Collections, file I/O, networking, dates, concurrency — all built in
Massive job market Java developers are in demand all over the world

How a Java program runs

  1. You write source code in a file ending in .java.
  2. The compiler javac translates it into bytecode stored in a .class file.
  3. The JVM (java) loads the bytecode and runs it, compiling hot code paths to fast machine code on the fly.

You do not need to install anything to follow this course: every example on ExcelTAD is compiled and run on a real JDK in the cloud.

Your first Java program

Every Java program starts in a method called main that lives inside a class. Press ▶ Run to compile and run this program, then change the text and run it again.

java · try it yourself
class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
Hello, World!

System.out.println prints a line of text followed by a line break. Don't worry about public static void and String[] args yet — the Syntax chapter explains every word.

Tip: In every playground on ExcelTAD you can edit the code and press Ctrl+Enter to run it.

Printing several lines

Statements inside main run from top to bottom, one after another:

java · try it yourself
class Main {
    public static void main(String[] args) {
        System.out.println("Java is portable.");
        System.out.println("Java is object-oriented.");
        System.out.println("Java is everywhere!");
    }
}
Java is portable.
Java is object-oriented.
Java is everywhere!

Java vs. other languages

Java Python C++
Typing static dynamic static
Runs on JVM (bytecode) interpreter native machine code
Memory garbage collected garbage collected manual / RAII
Syntax family C-style braces { } indentation C-style braces { }

If you already know C, C++ or C#, Java's syntax will look very familiar. If you come from Python, the biggest change is that every variable has a fixed type and every statement ends with a semicolon.

Note: Java and JavaScript are completely different languages. The similar name was a marketing decision in the 1990s.

Test yourself

What does the Java compiler javac produce?

  1. Machine code for one CPU
  2. Bytecode in .class files
  3. A Python script
  4. HTML pages

Which method does a Java program start running from?

  1. start()
  2. run()
  3. main()
  4. init()

What does JVM stand for?

  1. Java Variable Manager
  2. Java Virtual Machine
  3. Joint Vector Module
  4. Java Version Monitor