Java: From Zero to Your First
Program!
A Beginner's Guide to Building with
the World's Most Versatile Language
(Visual: Java logo ☕, laptop 💻 on a
dynamic background)
A Powerful, All-Purpose Language
• Key Phrase: "Write Once, Run Anywhere" (WORA)
• Java code can run on almost any device, making it incredibly powerful and
versatile.
Why Learn Java?
• Object-Oriented: Organizes code like the real world.
• Platform Independent: "Write Once, Run Anywhere."
• Huge Community: Endless help, libraries, and resources.
• Secure & Reliable: Trusted by banks and enterprises.
Java is Everywhere!
• Used by Netflix, LinkedIn, Android, banking systems, scientific computing,
and even Minecraft!
The Magic Trio: JDK, JRE, and JVM
• JDK (Java Development Kit): Complete toolbox for developers.
• JRE (Java Runtime Environment): Needed to run Java apps.
• JVM (Java Virtual Machine): Executes the bytecode.
Visualizing the Trio
• JDK ➜ JRE ➜ JVM (Developer → User's Machine → Execution Engine)
Your Developer Toolkit
• JDK – The Core Engine
• Visual Studio Code – Great for beginners
• IntelliJ IDEA – Powerful and professional
Your First Program: "Hello, World!"
• public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Let's Run It!
• Compile: javac HelloWorld.java → HelloWorld.class
• Run: java HelloWorld → Output: Hello, World!
Classes & Objects
• Class: The blueprint (like a cookie cutter).
• Object: The created instance (like each cookie).
Dissecting "Hello, World!" – The
Class
• public – Visible to everyone
• class – Declares a blueprint
• HelloWorld – Name of the blueprint
Dissecting "Hello, World!" – The
Main Method
• public static void – Special keywords
• main – Program entry point
• String[] args – Accepts command‑line arguments
Dissecting "Hello, World!" – The
Action
• System.out.println("Hello, World!"); – Prints text to console
Giving Your Data a Home
• Variables store information of different types.
Primitive Types (The Basics)
• int – Whole numbers
• double – Decimal numbers
• char – Single character
• boolean – True or false
Non‑Primitive Types (Objects)
• String – Text like "Hello World" (actually a class!)
Declaring Variables
• Syntax: [Type] [Name] = [Value];
• Example: int age = 25;
The Action Symbols of Java
• Operators perform actions on variables.
Arithmetic Operators
• + 10 + 5 = 15
• - 10 - 5 = 5
• * 10 * 5 = 50
• / 10 / 5 = 2
• % 10 % 3 = 1 (remainder)
Interactive Addition Program
• Write a program that asks for two numbers and prints their sum.
Assignment Operators
• x += 5; // same as x = x + 5;
Relational Operators
• > Greater than
• < Less than
• >= Greater or equal
• == Equal
• != Not equal
Relational Operators in Action
• int a = 10;
int b = 5;
System.out.println(a > b); // true
System.out.println(a == b); // false
Logical Operators
• && AND – both conditions true
• || OR – either condition true
• ! NOT – reverses condition
Logical Operators Example
• Conditions: Age >= 25 AND Has License → You can rent a car!
Unary Operators
• score++; // adds one to score
Pre vs. Post Increment
• score++ – use, then increment
• ++score – increment, then use
Challenge: Simple Interest
Calculator
• Task: Write program to calculate Interest = P * R * T / 100
Advanced Operators (A Quick Look)
• Bitwise &, | and ternary ? : for advanced tasks.
You Did It!
• Understood what Java is and why it's used.
• Learned the difference between a Class and an Object.
• Used basic operators to build a calculator!
What's Next?
• Decisions (if/else)
• Repetition (for & while loops)
• Arrays – storing lists of data
The Power of Practice
• Programming skill grows by building projects.
Recommended Resources
• Oracle Docs
• GeeksforGeeks
• W3Schools
• Head First Java (book)
Questions?
• Feel free to ask anything!
Thank You!
• Happy Coding!
• (Add your name & contact)