Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 01 / 801%· free preview
Getting Started1/4

Java Introduction

What Java is, why 'Write Once Run Anywhere' still matters, and how it differs from Python/C.

What is Java?

Java is a general-purpose, object-oriented, statically-typed, compiled-to-bytecode programming language created by James Gosling at Sun Microsystems in 1995 (now owned by Oracle). It runs on the JVM (Java Virtual Machine) — so the same compiled .class file runs on Windows, Linux, macOS, and Android.

In simple words:

  • Java is C++ with a safety net — adds garbage collection, no raw pointers, and a huge standard library.
  • It compiles to bytecode (not native code) and the JVM JIT-compiles it to machine code at runtime.
  • Famous slogan: "Write Once, Run Anywhere" (WORA) — one binary, every platform with a JVM.
  • Powers everything from Android apps and banking systems to Netflix, LinkedIn, Spotify, and Minecraft.
Why Learn Java?
  • Job market — #1 enterprise language. Banks, fintech, telecom, and government all run on Java.
  • Android — native Android apps are Java/Kotlin (Kotlin compiles to JVM bytecode too).
  • Beginner-friendly — strong types catch bugs at compile time, not in production.
  • Massive ecosystem — Spring, Hibernate, Maven, Gradle, JUnit, IntelliJ.
  • Performance — JIT-compiled, often within 10% of C++ for server workloads.
  • Career stability — Java skills are in demand for the next 20 years (banks won't rewrite COBOL/Java overnight).
What You Can Build with Java?
DomainReal-world Example
Mobile appsAndroid (Java + Kotlin)
Web back-endsNetflix, LinkedIn, Uber, Twitter (early years)
Banking / FintechGoldman Sachs, JPMorgan, ICICI core banking
Big DataHadoop, Spark, Kafka, Cassandra
EnterpriseSAP, Oracle ERP, Salesforce back-end
GamesMinecraft (Java Edition), RuneScape
IoT / EmbeddedJava ME, smart-card chips, Blu-ray players
Java vs C, C++, Python — Quick Compare
FeatureCC++PythonJava
ParadigmProceduralMulti-paradigmMulti-paradigmOOP-first
Compiled toNativeNativeBytecode (interpreted)Bytecode (JIT)
Memory mgmtManualManual + smart ptrsGCGC (automatic)
PointersYesYesNoNo (references only)
Static / Dynamic typingStaticStaticDynamicStatic
SpeedFastestFastestSlowestFast (close to C++)
Platform-independent binaryNoNoSource-onlyYes (.class runs anywhere)
File extension.c.cpp.py.java.class
Your First Java Program
java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Codekilla!");
    }
}
Hello, Codekilla!
Line-by-Line Explanation
  • public class HelloWorld { ... } — every Java program lives inside a class. The file name must match the public class name (HelloWorld.java).
  • public static void main(String[] args) — the entry point. The JVM looks for this exact signature.
    • public — accessible from outside the class.
    • static — belongs to the class, no instance needed.
    • void — returns nothing.
    • String[] args — command-line arguments as an array.
  • System.out.println("..."); — prints a line (println = print + newline) to standard output.
  • Every statement ends with a semicolon ; — Java is strict about it.
Compile and Run
bash
javac HelloWorld.java   # produces HelloWorld.class (bytecode)
java HelloWorld         # runs the class on the JVM (no .class extension!)
Common Mistakes
  • File name mismatchpublic class HelloWorld must live in HelloWorld.java. Capital matters.
  • Forgetting ; — every statement ends with a semicolon. The compiler points at the next line.
  • Wrong casePublic or Static won't compile. Java is case-sensitive.
  • Running java HelloWorld.class — drop the .class. Pass the class name, not the file.
  • No main methodError: Main method not found in class ....
Interview Questions

Practice Exercises
  1. Hello on three lines — Print your name, age, and city on three separate lines using three println calls. Hint: three statements, each ending in ;.
  2. Filename check — Save a file as Hello.java containing public class HelloWorld. Compile it — note the error. Hint: rename the file to match the class.
  3. Compile + run — Use javac and java on your machine and confirm output matches. Hint: install JDK 17+ first.
  4. No static — Remove static from main and try to run. Read the error. Hint: JVM can't call non-static main without an instance.

💡 Think Like a Programmer: Compile errors are your friend. They catch typos and type mismatches before users do. Read them top-to-bottom — the first error often causes the rest.

AI-powered recap

Quick recap quiz?

We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.

# program

Program

Java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, Codekilla!");
    }
}
Ready to move on?
// example library
Want more hands-on snippets in Java?
Browse 100 runnable examples · across 10 chapters · short, copy-paste-friendly · grouped by topic
Explore examples
// side-by-side reference
See this in other languages
Compare the same concept across C, C++, Java, and Python — one table, zero tab-switching.
Compare Languages
// feedback.matters()
Did this lesson help you?
100% found this helpful · 1 vote