A comprehensive developer's handbook to Java. Deep-dive into JVM heap architectures, Collections framework, functional Streams, Garbage Collection, multithreading, and Spring Boot backends.
Understanding Java requires tracing how code compiles and executes:
javac (compiler) and jdb (debugger).[Java Code (.java)] ──► javac Compiler ──► [Bytecode (.class)] ──► JVM Executed
Java enforces class-based development. Every program consists of structured classes.
package com.ajitdev;
public class Employee {
private String name;
private double salary;
public Employee(String name, double salary) {
this.name = name;
this.salary = salary;
}
public void displayDetails() {
System.out.println("Employee Name: " + name + ", Salary: $" + salary);
}
public static void main(String[] args) {
Employee emp = new Employee("Ajit Dev", 85000);
emp.displayDetails();
}
}
The Collections framework inside java.util offers standardized data collections:
List: Ordered lists (ArrayList, LinkedList).Set: Unordered, unique collections (HashSet, TreeSet).Map: Key-value pairs (HashMap, TreeMap).import java.util.*;
public class CollectionDemo {
public static void main(String[] args) {
List<String> skills = new ArrayList<>();
skills.add("Java");
skills.add("Spring Boot");
skills.add("AWS");
Collections.sort(skills);
System.out.println("Sorted Skills: " + skills);
}
}
Introduced in Java 8, Streams allow declarative processing of collections.
import java.util.*;
import java.util.stream.*;
public class StreamsDemo {
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(10, 15, 20, 25, 30);
// Filter out odd numbers and double the values
List<Integer> results = numbers.stream()
.filter(n -> n % 2 == 0)
.map(n -> n * 2)
.collect(Collectors.toList());
System.out.println("Transformed: " + results);
}
}
JVM memory is split into:
Garbage Collection sweeps the heap automatically. Major GC algorithms include G1 (Garbage First) and ZGC (Z Garbage Collector), which optimize pauses.
Java supports concurrent threading using the Thread class, Runnable interface, and the modern ExecutorService framework.
import java.util.concurrent.*;
public class ConcurrencyDemo {
public static void main(String[] args) {
ExecutorService executor = Executors.newFixedThreadPool(2);
executor.submit(() -> System.out.println("Thread 1 running task"));
executor.submit(() -> System.out.println("Thread 2 running task"));
executor.shutdown();
}
}
Spring Boot is an extension of the Spring Framework, designed to set up production-ready web servers with minimal config:
@Autowired).package com.ajitdev.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemoApplication {
@GetMapping("/api/greet")
public String greet() {
return "Hello from Spring Boot, powered by Ajit Dev!";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
equals() and ==?
== checks reference equality (are they the same object in memory), whereas equals() checks logical value equality.try-catch or throws), while Unchecked exceptions (RuntimeException) are evaluated at runtime.CTO @ Brainzima Innovation Institute 🚀 · Full Stack Developer & DevOps Engineer
Ajit Dev (also known as Ajit Kumar) is based in Katihar, Bihar, India. Specializing in MERN Stack, Next.js, Cloud Security, and Distributed Systems.