Java Basics, Java Programming · December 2, 2026

Java for Beginners, Lesson 1: What is Java? Features and Uses

Java for Beginners · Module 1: Getting Started


🎯 Why Start with Java?

Imagine writing one letter that every post office in the world can read, whatever language its staff speak. That is the dream Java was built for: write your program once, and run it on any computer that has Java installed.

Today Java is used by millions of developers. It runs banking systems, Android apps, large websites and the tools programmers use every day. It is also one of the best first languages, because it teaches you good habits: clear structure, strict types and object-oriented thinking.

📌 Java is a general-purpose, object-oriented programming language that runs on the Java Virtual Machine (JVM). You will meet the JVM properly in Lessons 3 and 4. For now, remember that Java programs do not run directly on Windows or Linux. They run on the JVM, which sits in between.

1️⃣ A Short History

Java was announced in 1995 by Sun Microsystems. The team was led by James Gosling, and the language was first called Oak. Oracle bought Sun in 2010 and now looks after Java. New versions arrive every six months, and some are marked LTS (Long-Term Support). LTS versions get updates for many years, so companies prefer them.

1995
Sun Microsystems announces Java
1996
JDK 1.0, the first release
2010
Oracle acquires Sun
2014
Java 8 adds lambdas
2018
Java 11 (LTS)
2021
Java 17 (LTS)
2023
Java 21 (LTS)
2025
Java 25 (LTS)

Figure 1: Important moments in Java's history. LTS versions are shown in green.

💡 Which version should you use? Any recent LTS version, such as Java 17, 21 or 25, is fine for this series. Everything we teach works on all of them.

2️⃣ Write Once, Run Anywhere

When you compile a C program, you get machine code for one kind of computer. A Windows program does not run on Linux. Java does something different: the compiler turns your code into bytecode, a neutral format. Each computer has its own JVM that understands bytecode, so the same file runs everywhere.

Hello.java
source code you write
⬇ javac (compiler)
Hello.class
bytecode: one file for every computer
⬇ same file copied to each system
Windows
JVM for Windows
▶ runs
Linux
JVM for Linux
▶ runs
macOS
JVM for macOS
▶ runs

Figure 2: One source file, one bytecode file, and a JVM on each operating system.

This idea is called WORA, for “Write Once, Run Anywhere”. You will study it in detail in Lesson 3.

3️⃣ Key Features of Java

FeatureWhat it means for you
Simpleno pointers or manual memory
Object-orientedprograms built from objects
Platform independentbytecode runs on any JVM
Secureruns inside a controlled JVM
Robuststrong type checking, exceptions, garbage collection
Multithreadedmany tasks at once

Figure 3: The main features of Java.

  • Simple: Java removed hard parts of C and C++, such as pointers and manual memory freeing.
  • Object-oriented: you build programs from objects that combine data and actions. You will start this in Lesson 29.
  • Platform independent: bytecode runs on any JVM.
  • Secure: programs run inside the JVM, which controls what they can do.
  • Robust: Java checks types strictly, reports errors as exceptions, and cleans up unused memory automatically (garbage collection).
  • Multithreaded: a program can do several tasks at the same time.

4️⃣ Where Is Java Used?

📱 Android apps
Many Android apps are written in Java
🌐 Web servers
Spring and other frameworks run websites and APIs
🏦 Banking
Banks use Java for secure, reliable systems
📊 Big data
Tools such as Hadoop and Kafka are built on the JVM
🖥️ Desktop tools
IDEs like IntelliJ IDEA and Eclipse are Java programs
🎓 Education
A standard first language in many universities

Figure 4: Some places where Java is used in the real world.

5️⃣ Java and C Side by Side

If you already know a little C, this table shows what changes in Java.

CJava
Compiled tomachine code for one OSbytecode for the JVM
Runs onthe OS directlythe JVM, on any OS
Memoryyou allocate and freegarbage collector frees it
Pointersyesno (references instead)
Styleproceduralobject-oriented
Portabilityrecompile for each OScompile once, run anywhere

Figure 5: C and Java compared.

6️⃣ Your First Look at Java Code

Do not worry about understanding every word yet. Lesson 5 explains each line. For now, just see that Java is readable.

Program 1: The smallest useful program

public class HelloJava {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}
🖥️ Output:
Hello, Java!
  • public class HelloJava creates a class. In Java every program lives inside a class, and the file must be named HelloJava.java.
  • public static void main(String[] args) is where the JVM starts running.
  • System.out.println(...) prints text and moves to the next line.

Program 2: print and println

public class AboutMe {
    public static void main(String[] args) {
        System.out.print("Language: ");
        System.out.println("Java");
        System.out.println("Created in: 1995");
        System.out.println("Used for: apps, websites, servers");
    }
}
🖥️ Output:
Language: Java
Created in: 1995
Used for: apps, websites, servers
  • print stays on the same line, so “Language: ” and “Java” join.
  • println ends the line, so the next output starts below.

Program 3: Adding two numbers

public class SimpleAddition {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int sum = a + b;
        System.out.println("Sum = " + sum);
    }
}
🖥️ Output:
Sum = 30
  • int a = 10; creates a whole-number variable named a holding 10.
  • "Sum = " + sum joins text with a number to build one message.

Program 4: Area of a circle

public class CircleArea {
    public static void main(String[] args) {
        double radius = 3.5;
        double area = Math.PI * radius * radius;
        System.out.println("Radius = " + radius);
        System.out.println("Area   = " + area);
        System.out.printf("Area (2 decimals) = %.2f%n", area);
    }
}
🖥️ Output:
Radius = 3.5
Area = 38.48451000647496
Area (2 decimals) = 38.48
  • double holds numbers with decimals.
  • Math.PI is a ready-made constant from Java’s standard library.
  • %.2f in printf prints 2 digits after the decimal point, and %n starts a new line.

Program 5: A method and a loop

public class TwoThings {
    static int square(int n) {
        return n * n;
    }

    public static void main(String[] args) {
        for (int i = 1; i <= 5; i++) {
            System.out.println(i + " squared is " + square(i));
        }
    }
}
🖥️ Output:
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25
  • square is a small method (the Java word for a function) that returns n * n.
  • The for loop calls it five times. If you know C functions, this will feel familiar.

⚠️ Common Beginner Mistakes

MistakeWhy it is wrongFix
Saying “Java and JavaScript are the same”They are different languages with similar namesJava runs on the JVM; JavaScript runs in browsers
Expecting Java to be machine codeJava compiles to bytecodeRemember: source, then bytecode, then JVM
Naming the file differently from the public classThe compiler reports an errorClass HelloJava goes in HelloJava.java
Writing system.out.printlnJava is case-sensitive: System has a capital SWrite System.out.println
Forgetting the semicolonEvery statement ends with ;Add ; at the end

❓ Frequently Asked Questions

Q1. Is Java free?
Yes. OpenJDK is free and open source, and you can use it to learn and to build real projects.

Q2. Is Java hard to learn?
It is stricter than some languages, but that strictness catches mistakes early. If you know basic C, you will find many ideas familiar.

Q3. Is Java still relevant?
Yes. It is used widely in companies, in Android development and in backend systems, and new versions keep arriving.

Q4. Do I need to know C first?
No. This series starts from zero.

✅ Key Takeaways

  • Java is a general-purpose, object-oriented language created at Sun Microsystems and now maintained by Oracle.
  • Source code compiles to bytecode, which runs on the JVM of any operating system.
  • Java’s main features are simple, object-oriented, platform independent, secure, robust and multithreaded.
  • Java is used for Android apps, web servers, banking, big data and desktop tools.
  • Choose a recent LTS version (17, 21 or 25) for learning.
🎓 Practice questions: (1) In your own words, what does “Write Once, Run Anywhere” mean? (2) What is bytecode, and who runs it? (3) Name three differences between C and Java from the table. (4) Change Program 2 to print your own name and college. (5) Change Program 4 to calculate the area for a radius of 10.
All 30 lessons in this series (open course page)

Module 1 · Getting Started

Module 2 · Building Blocks

Module 3 · Operators

Module 4 · Control Flow

Module 5 · Data and Methods

Module 6 · Objects and Revision