A hands-on, example-driven Java learning repository — from zero to OOP hero.
"Learning Java one concept at a time — clean code, clear examples, no fluff."
java-tutorial is a structured, example-first repository built to teach core Java concepts through practical, runnable code. With 327+ commits and growing, it's a living reference for developers at every stage — whether you're writing your first class or revisiting fundamentals before an interview.
Each folder isolates one concept, with focused .java files you can read, run, and experiment with immediately. No frameworks, no setup headaches — just pure Java.
☕ java-tutorial/
│
├── 📂 Access-Modifiers/ # public, private, protected, default — demystified
├── 📂 Consept-Of-Object-Oriented/ # The 4 pillars of OOP with real examples
├── 📂 Constructor/ # Default, parameterized & overloaded constructors
│
└── 📄 README.md
Control who can see and touch your code.
| Modifier | Visibility |
|---|---|
public |
Accessible from anywhere |
protected |
Same package + subclasses |
default |
Same package only |
private |
Class-only access |
Learn when and why to use each modifier — a critical skill for writing safe, maintainable Java.
The four pillars that make Java Java.
| Pillar | What It Means |
|---|---|
| 🔒 Encapsulation | Bundle data and methods; hide internals |
| 🧬 Inheritance | Reuse and extend existing classes |
| 🎭 Polymorphism | One interface, many implementations |
| 🎨 Abstraction | Expose what matters, hide the rest |
Practical code examples show each concept in action — not just definitions.
How Java objects are born.
- Default Constructor — no arguments, sensible defaults
- Parameterized Constructor — initialize with specific values
- Constructor Overloading — multiple signatures, flexible creation
this()chaining — constructor calling constructor
- ✅ JDK 8+ installed
- ✅ Any IDE: IntelliJ IDEA, Eclipse, or VS Code with Java extension
- ✅ Basic familiarity with running terminal commands
# Clone the repository
git clone https://github.com/MisaghMomeniB/java-tutorial.git
# Move into the project
cd java-tutorial
# Navigate to a topic folder
cd Access-Modifiers
# Compile a file
javac FileName.java
# Run it
java FileNameFollow this order for the smoothest journey from beginner to confident Java developer:
1️⃣ Access-Modifiers
│
▼
2️⃣ Constructor
│
▼
3️⃣ Consept-Of-Object-Oriented
│
▼
4️⃣ Build your own Java project! 🚀
Each step builds on the last. Don't skip — understanding access modifiers makes OOP click much faster.
public class BankAccount {
private double balance; // only this class can access it
protected String ownerName; // accessible by subclasses
public String accountId; // everyone can see this
public double getBalance() { // controlled access via public method
return balance;
}
}public class Person {
String name;
int age;
// Default constructor
Person() {
this.name = "Unknown";
this.age = 0;
}
// Parameterized constructor
Person(String name, int age) {
this.name = name;
this.age = age;
}
}
// Usage
Person p1 = new Person(); // → Unknown, 0
Person p2 = new Person("Misagh", 25); // → Misagh, 25class Animal {
void speak() {
System.out.println("...");
}
}
class Dog extends Animal {
@Override
void speak() {
System.out.println("Woof! 🐕");
}
}- Access Modifiers
- Constructors
- OOP Concepts (Encapsulation, Inheritance, Polymorphism, Abstraction)
- Exception Handling
⚠️ - Collections Framework (List, Map, Set) 📚
- Interfaces & Abstract Classes 🎭
- Generics 🔮
- File I/O 📁
- Multithreading 🧵
- Java Streams & Lambda Expressions ⚡
All contributions are welcome — whether it's a new topic, a cleaner example, or a typo fix!
- Fork the repo
- Create a branch:
git checkout -b topic/your-topic - Add your Java files with clear comments
- Commit:
git commit -m "Add: topic name" - Push and open a Pull Request
Please keep examples focused, well-commented, and beginner-friendly.
Distributed under the MIT License — free to use, learn from, and share.