🚀 My First Steps in Java: Hello World, Java Structure & Arithmetic Operations

By Abhi Yadav — documenting my journey into Java, one concept at a time.
👋 Getting Started with Java
I've officially started learning Java, and like every developer's first milestone, I began with the classic:
javaCopy codeSystem.out.println("Hello World");
It may look simple, but this one-liner holds the key to understanding how Java handles syntax, structure, and output. Let me walk you through everything I’ve learned so far — with real code and notes.
📦 Step 1: My First Java Program
File Name: Hello.java
javaCopy codepublic class Hello {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
✅ What’s happening here?
public class Hello
→ This is the class declaration. The filename and class name must match.public static void main(String[] args)
→ This is the entry point of every Java program.System.out.println()
→ Prints text to the console.
💡 Output:
nginxCopy codeHello World
🧱 Step 2: Java Structure and Comments
File Name: hello-2.java
This second file taught me the structure of a Java program and how to use comments.
javaCopy codepublic class HelloStructure {
public static void main(String[] args) {
// Single-line comment
/*
Multi-line comments help you explain
parts of code in detail
*/
System.out.println("Learning Java Structure");
}
}
🧠 Key Concepts:
Single-line comments: Start with
//
Multi-line comments: Begin with
/*
and end with*/
Every Java program must have a class, and the execution always starts from the
main()
method.
🖨 Output:
vbnetCopy codeLearning Java Structure
➗ Step 3: Arithmetic Operators in Java
File Name: airthmetic_
operator.java
This is where I dove into math operations, augmented assignments, and even order of operations (PEMDAS style 😄).
javaCopy codepublic class airthmetic_operator {
public static void main(String[] args) {
int x = 10;
int y = 2;
int z;
z = x / y;
System.out.println(z); // Output: 5
You can also try other operators like:
javaCopy code// z = x + y;
// z = x - y;
// z = x * y;
// z = x % y;
🧮 Augmented Assignment Operators
Java supports shorthand like:
javaCopy codex += y; // same as x = x + y;
x -= y;
x *= y;
x /= y;
x %= y;
System.out.println(x);
📈 Increment & Decrement
javaCopy codeint c = 1;
c++; // increment
c--; // decrement
System.out.println(c); // Output: 1 (increment then decrement)
🧮 Order of Operations (PEMDAS in action!)
javaCopy codedouble result = 3 + 4 * (7 - 5) / 2.0;
System.out.println(result); // Output: 7.0
Java respects parentheses → exponents → multiplication/division → addition/subtraction just like math.
➕ Final Practice
javaCopy codeint a = 5;
int b = 10;
int d = 15;
int num = a + b + d;
System.out.println("Addition: " + num); // 30
int num2 = (d - a) - b;
System.out.println("num = " + num2); // 0
💭 What I’ve Learned So Far
✅ How to write and run my first Java program
✅ Java class structure, main method, and syntax
✅ Using comments for clarity
✅ Arithmetic operations and augmented assignments
✅ Increment/decrement operators
✅ How Java handles operator precedence
📌 What’s Next?
In my next post, I’ll cover:
if-else
conditionsLoops (
for
,while
)And maybe a mini project to test what I’ve learned 🔥
If you're just starting Java too →let’s connect!
Leave a comment or suggestion if you're on the same journey 💬
🧠 Blog by Abhi Yadav
🎯 Learning Java. Building in public.
📍 Follow me on X (Twitter)
Subscribe to my newsletter
Read articles from Abhi Yadav directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
