☕ Java — Learn From Zero
Playground: Replit Java | JDoodle — click, type, run.
What is Java?
Java is a statically-typed, object-oriented language that runs on the JVM. Write once, run anywhere. Used in enterprise, Android, and big systems.
- Android apps
- Enterprise backends (Spring)
- Big data (Hadoop, Spark)
- Cross-platform tools
Run Online — No Install
Use the playground links above.
🟢 Beginner — Core Basics
Your First Program
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}Execution starts in main.
Variables & Types
int age = 36;
double height = 1.78;
boolean isStudent = true;
String name = "Ada";Types are explicit: int, double, boolean, String.
If / Else
int age = 18;
if (age >= 18) System.out.println("Vote");
else System.out.println("Too young");Curly braces group statements.
Loops
for (int i = 0; i < 5; i++) System.out.println(i);
int n = 3;
while (n-- > 0) System.out.println(n);Same loop styles as C-style languages.
Methods
static int add(int a, int b) {
return a + b;
}Functions inside classes are called methods.
Arrays & Lists
String[] fruits = {"apple", "banana"};
java.util.List list = new java.util.ArrayList<>(); Prefer List over raw arrays.
🟡 Intermediate — Building Real Programs
Classes & Objects
class Person {
String name;
Person(String n) { name = n; }
}Encapsulate data in classes.
OOP Principles
interface Animal { void speak(); }
class Dog implements Animal {
public void speak() { System.out.println("Woof"); }
}Use interface and implements.
Exceptions
try {
int x = 1 / 0;
} catch (ArithmeticException e) {
System.out.println("No divide by zero");
}Catch errors with try/catch.
Collections
java.util.Map m = new java.util.HashMap<>();
m.put("Ada", 36); Use Map, Set, List.
Streams
List nums = List.of(1,2,3,4);
long even = nums.stream().filter(n -> n % 2 == 0).count(); Functional pipelines with streams.
🔴 Advanced — Pro Concepts
Generics
class Box {
T value;
Box(T v) { value = v; }
} Parameterize types safely.
Lambdas
Runnable r = () -> System.out.println("Hi");
new Thread(r).start();Lambdas are anonymous functions.
Records (Java 16+)
record Point(int x, int y) {}
Point p = new Point(1, 2);Compact immutable data classes.
Concurrency
ExecutorService ex = Executors.newFixedThreadPool(2);
ex.submit(() -> System.out.println("Task"));Use executors, not raw threads.
What's Next?
- Build a tiny project: Calculator, To-Do App, Weather Widget
- Read the official docs and a good book
- Solve Exercism exercises
- Join a community & share your code
Practice daily for 20 minutes. Consistency > intensity.