Java: From Zero to Your First Program!
A Beginner’s Guide to Building with the World’s Most Versatile Language
What is Java?
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, making it easier to manage.
Platform Independent: "Write Once, Run Anywhere."
Huge Community: Endless help, libraries, and resources are available online.
Secure & Reliable: Trusted by banks and large companies for its security.
What is Java Used For?
Java is Everywhere!
Netflix, LinkedIn, Android, Banking Apps, Scientific Computing, Minecraft
The Magic Trio: JDK, JRE, and JVM
JDK (Java Development Kit): The complete toolbox for developers.
JRE (Java Runtime Environment): What users need to run your application.
JVM (Java Virtual Machine): The engine that executes the code.
Visualizing the Trio
Funnel View:
JDK -> JRE -> JVM
Setting Up Your Workspace
Your Developer Toolkit:
JDK, Visual Studio Code, IntelliJ IDEA
Your First Program: 'Hello, World!'
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Let's Run It!
HelloWorld.java -> javac -> HelloWorld.class -> java -> "Hello, World!"
The Big Ideas: Classes & Objects
Class: The blueprint.
Objects: The actual things you create from the blueprint.
Dissecting 'Hello, World!' - The Class
public: "Everyone can see and use this."
class: "This is a blueprint."
HelloWorld: "The name of our blueprint."
Dissecting 'Hello, World!' - The Main Method
public static void: "Specific instructions for the front door."
main: "The name of the front door. This is where the program starts!"
Dissecting 'Hello, World!' - The Action
System.out.println(...): This line tells the system to print something to the output console.
Data Types: Storing Information
Variables are containers that hold different types of information.
Primitive Types (The Basics)
int - For whole numbers
double - For decimal numbers
char - For a single character
boolean - For true or false
Non-Primitive Types (Objects)
String is the most common. It's for text, like "Hello World". It's actually a class!
Declaring Variables
Syntax: [Type] [Name] = [Value];
Example: int age = 25;
What are Operators?
Operators are symbols that perform actions on your variables.
Arithmetic Operators
+: 10 + 5 = 15
-: 10 - 5 = 5
*: 10 * 5 = 50
/: 10 / 5 = 2
%: 10 % 3 = 1
Interactive Addition Program
Write a program to take two numbers and print their sum.
Assignment Operators
x += 5; is the same as x = x + 5;
Relational Operators
Compare values and return true or false.
Example: 10 > 5 is true
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 must be true
|| (OR): either must be true
Logical Operators Example
Checklist:
Age >= 25: ✓
Has License: ✓
You can rent a car!
Unary Operators
score++; adds one to score.
Pre vs. Post Increment
score++: use then add
++score: add then use
Challenge: Simple Interest Calculator
Interest = P * R * T / 100
Write a program to calculate it.
Advanced Operators (A Quick Look)
Operators like &, |, ? : for advanced logic. Learn them later.
You Did It!
[✓] Understood Java
[✓] Learned Classes and Objects
[✓] Used Operators
What's Next?
Decisions (if/else)
Repetition (loops)
Arrays
The Power of Practice
Programming is a skill built by doing. The more you build, the better you get!
Recommended Resources
Oracle, GeeksforGeeks, W3Schools, Head First Java
Q&A Session
Questions?
Thank You!
Happy Coding!
(Include your name and contact info)