Java Developer Complete Guide

From zero to job-ready. Master Java development with plain-English guidance, real-world examples, and hands-on projects. Written for absolute beginners and aspiring developers.

Learning Path
12-16 wks
Average Salary
$70K-$165K
Job Growth
22% by 2030

Search notes

Type a topic and jump to answers.

Uses the same instant search approach as Bench Sales Notes. Shorter layout so you can see more content at once.

Start typing to filter sections.

    What is Java?

    Simple Explanation

    Java is a programming language that lets you write instructions for computers. Think of it as teaching a robot to perform tasksβ€”you write code, and the computer executes it. Java is used to build websites, mobile apps (Android), enterprise systems, and cloud applications.

    • Role: Backend developer, full-stack engineer, Android developer, enterprise architect.
    • Goal: Learn Java fundamentals in 12-16 weeks and land your first job.
    • Salary: Junior: $70K-$85K | Mid: $95K-$125K | Senior: $130K-$165K.
    Why Learn Java?
    • High demand: 3 million+ jobs globally; used by Google, Amazon, Netflix, banks.
    • Beginner-friendly: Clear syntax, strong community, tons of tutorials.
    • Cross-platform: "Write once, run anywhere"β€”works on Windows, Mac, Linux.
    • Career growth: Path from junior dev β†’ senior β†’ architect β†’ team lead.
    • Ecosystem: Spring Boot, Hibernate, Microservices, Cloud (AWS/Azure).
    Quick Q&A

    Do I need a CS degree? No. Self-taught developers get hired if they build projects and pass interviews.

    How long to become job-ready? 12-16 weeks with 15-20 hours/week of focused practice.

    What tools do I need? JDK, IntelliJ IDEA (or Eclipse), Git, and a GitHub account.

    Is Java still relevant in 2025? Yes. Java powers 90% of Fortune 500 backend systems.

    Your 12-Week Roadmap
    • Weeks 1-4: Java basics (syntax, loops, conditionals, methods).
    • Weeks 5-7: OOP (classes, inheritance, interfaces, polymorphism).
    • Weeks 8-9: Collections, Exception Handling, File I/O.
    • Weeks 10-11: Spring Boot basics, REST APIs, CRUD operations.
    • Week 12: Build 2-3 portfolio projects and prep resume.

    Core Java Fundamentals

    Setting Up Your Environment

    Step 1: Download and install JDK (Java Development Kit) from Oracle or use OpenJDK.

    Step 2: Install IntelliJ IDEA Community Edition (free) or Eclipse.

    Step 3: Verify installation by typing java -version in terminal/command prompt.

    Step 4: Create your first project: File β†’ New Project β†’ Java β†’ Hello World.

    Your First Java Program
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello, World!");
        }
    }
    

    Explanation:

    • public class HelloWorld β€” Defines a class named HelloWorld.
    • public static void main β€” Entry point; program starts here.
    • System.out.println β€” Prints text to console.
    Variables and Data Types

    Variables store data. Java has 8 primitive types:

    Type Size Example Use Case
    int 4 bytes int age = 25; Whole numbers
    double 8 bytes double price = 99.99; Decimal numbers
    boolean 1 bit boolean isActive = true; True/false flags
    char 2 bytes char grade = 'A'; Single character
    String Object String name = "John"; Text/words
    Operators and Expressions
    int a = 10, b = 20;
    int sum = a + b;        // Addition: 30
    int diff = b - a;       // Subtraction: 10
    int product = a * b;    // Multiplication: 200
    int quotient = b / a;   // Division: 2
    int remainder = b % a;  // Modulus: 0
    
    boolean isEqual = (a == b);   // false
    boolean isGreater = (b > a);  // true
    
    Control Flow: If-Else
    int score = 85;
    
    if (score >= 90) {
        System.out.println("Grade: A");
    } else if (score >= 80) {
        System.out.println("Grade: B");
    } else if (score >= 70) {
        System.out.println("Grade: C");
    } else {
        System.out.println("Grade: F");
    }
    
    Loops: For, While, Do-While
    // For loop - when you know iteration count
    for (int i = 0; i < 5; i++) {
        System.out.println("Count: " + i);
    }
    
    // While loop - condition-based
    int count = 0;
    while (count < 5) {
        System.out.println("Count: " + count);
        count++;
    }
    
    // Do-While - executes at least once
    int num = 0;
    do {
        System.out.println("Number: " + num);
        num++;
    } while (num < 5);
    
    Methods (Functions)
    public class Calculator {
        // Method to add two numbers
        public static int add(int a, int b) {
            return a + b;
        }
        
        // Method with no return value
        public static void greet(String name) {
            System.out.println("Hello, " + name + "!");
        }
        
        public static void main(String[] args) {
            int result = add(10, 20);
            System.out.println("Sum: " + result);
            
            greet("John");
        }
    }
    

    Key Points:

    • public β€” Accessible from anywhere.
    • static β€” Can be called without creating an object.
    • int β€” Return type (use void for no return).
    • Parameters go inside parentheses: (int a, int b).

    Object-Oriented Programming (OOP)

    What is OOP?

    OOP is a programming style that organizes code into objectsβ€”real-world entities with properties (data) and behaviors (methods). Java is 100% object-oriented.

    Four Pillars of OOP:

    • Encapsulation: Bundle data and methods; hide internal details.
    • Inheritance: Reuse code by extending existing classes.
    • Polymorphism: One interface, multiple implementations.
    • Abstraction: Hide complexity; show only essential features.
    Classes and Objects
    // Define a class
    public class Car {
        // Properties (fields)
        String brand;
        String model;
        int year;
        
        // Constructor
        public Car(String brand, String model, int year) {
            this.brand = brand;
            this.model = model;
            this.year = year;
        }
        
        // Method (behavior)
        public void displayInfo() {
            System.out.println(year + " " + brand + " " + model);
        }
    }
    
    // Create objects
    public class Main {
        public static void main(String[] args) {
            Car car1 = new Car("Toyota", "Camry", 2023);
            Car car2 = new Car("Honda", "Accord", 2024);
            
            car1.displayInfo();  // Output: 2023 Toyota Camry
            car2.displayInfo();  // Output: 2024 Honda Accord
        }
    }
    
    Encapsulation (Getters and Setters)
    public class BankAccount {
        private double balance;  // Private = hidden from outside
        
        // Constructor
        public BankAccount(double initialBalance) {
            this.balance = initialBalance;
        }
        
        // Getter
        public double getBalance() {
            return balance;
        }
        
        // Setter with validation
        public void deposit(double amount) {
            if (amount > 0) {
                balance += amount;
            }
        }
        
        public void withdraw(double amount) {
            if (amount > 0 && amount <= balance) {
                balance -= amount;
            }
        }
    }
    

    Why Encapsulation? Protects data from invalid changes. You control access via methods.

    Inheritance
    // Parent class
    public class Animal {
        public void eat() {
            System.out.println("This animal eats food.");
        }
    }
    
    // Child class inherits from Animal
    public class Dog extends Animal {
        public void bark() {
            System.out.println("The dog barks.");
        }
    }
    
    public class Main {
        public static void main(String[] args) {
            Dog myDog = new Dog();
            myDog.eat();   // Inherited from Animal
            myDog.bark();  // Defined in Dog
        }
    }
    

    Use Case: Avoid code duplication. Common features go in parent class.

    Polymorphism
    // Method Overriding
    class Animal {
        public void makeSound() {
            System.out.println("Animal makes a sound");
        }
    }
    
    class Cat extends Animal {
        @Override
        public void makeSound() {
            System.out.println("Meow");
        }
    }
    
    class Dog extends Animal {
        @Override
        public void makeSound() {
            System.out.println("Bark");
        }
    }
    
    public class Main {
        public static void main(String[] args) {
            Animal myAnimal = new Dog();
            myAnimal.makeSound();  // Output: Bark (runtime polymorphism)
        }
    }
    
    Interfaces and Abstraction
    // Interface defines a contract
    interface Payable {
        void processPayment(double amount);
    }
    
    // Implement the interface
    class CreditCard implements Payable {
        @Override
        public void processPayment(double amount) {
            System.out.println("Processing $" + amount + " via Credit Card");
        }
    }
    
    class PayPal implements Payable {
        @Override
        public void processPayment(double amount) {
            System.out.println("Processing $" + amount + " via PayPal");
        }
    }
    

    When to use: When multiple classes share the same behavior but implement it differently.

    Collections Framework

    What are Collections?

    Collections are data structures that store groups of objects. Think of them as smart containers that automatically resize and provide useful methods.

    ArrayList - Dynamic Arrays
    import java.util.ArrayList;
    
    public class Main {
        public static void main(String[] args) {
            ArrayList fruits = new ArrayList<>();
            
            // Add items
            fruits.add("Apple");
            fruits.add("Banana");
            fruits.add("Orange");
            
            // Access items
            System.out.println(fruits.get(0));  // Apple
            
            // Size
            System.out.println("Size: " + fruits.size());
            
            // Loop through
            for (String fruit : fruits) {
                System.out.println(fruit);
            }
            
            // Remove item
            fruits.remove("Banana");
        }
    }
    

    Use Case: When you need a list that grows/shrinks dynamically.

    HashMap - Key-Value Pairs
    import java.util.HashMap;
    
    public class Main {
        public static void main(String[] args) {
            HashMap ages = new HashMap<>();
            
            // Add key-value pairs
            ages.put("John", 25);
            ages.put("Sarah", 30);
            ages.put("Mike", 28);
            
            // Get value by key
            System.out.println(ages.get("Sarah"));  // 30
            
            // Check if key exists
            if (ages.containsKey("John")) {
                System.out.println("John's age: " + ages.get("John"));
            }
            
            // Loop through
            for (String name : ages.keySet()) {
                System.out.println(name + " is " + ages.get(name) + " years old");
            }
        }
    }
    

    Use Case: Store data as pairs (like a dictionary). Fast lookups.

    HashSet - Unique Items Only
    import java.util.HashSet;
    
    public class Main {
        public static void main(String[] args) {
            HashSet uniqueNames = new HashSet<>();
            
            uniqueNames.add("Alice");
            uniqueNames.add("Bob");
            uniqueNames.add("Alice");  // Duplicate - won't be added
            
            System.out.println(uniqueNames);  // [Alice, Bob]
            System.out.println("Size: " + uniqueNames.size());  // 2
        }
    }
    

    Use Case: Remove duplicates automatically.

    Collections Comparison
    Collection Duplicates? Ordered? Best For
    ArrayList Yes Yes Lists, sequences
    HashMap Keys: No, Values: Yes No Key-value lookups
    HashSet No No Unique items
    LinkedList Yes Yes Frequent add/remove
    TreeSet No Sorted Sorted unique items

    Spring Boot Framework

    What is Spring Boot?

    Spring Boot is a framework that makes it easy to build production-ready web applications and REST APIs. It handles configuration automatically so you focus on business logic.

    Why Spring Boot?

    • 95% of Java backend jobs require Spring Boot experience.
    • Build REST APIs in minutes without complex XML configuration.
    • Includes embedded server (Tomcat) - no separate setup needed.
    • Integrates with databases, security, testing tools out-of-the-box.
    Creating Your First Spring Boot Project

    Step 1: Go to start.spring.io

    Step 2: Select: Maven, Java 17, Spring Boot 3.x

    Step 3: Add dependencies: Spring Web, Spring Data JPA, H2 Database

    Step 4: Generate and download the project

    Step 5: Open in IntelliJ, run DemoApplication.java

    Simple REST API Example
    import org.springframework.web.bind.annotation.*;
    import java.util.ArrayList;
    import java.util.List;
    
    @RestController
    @RequestMapping("/api/users")
    public class UserController {
        
        private List users = new ArrayList<>();
        
        // GET all users
        @GetMapping
        public List getAllUsers() {
            return users;
        }
        
        // GET user by ID
        @GetMapping("/{id}")
        public User getUserById(@PathVariable Long id) {
            return users.stream()
                .filter(u -> u.getId().equals(id))
                .findFirst()
                .orElse(null);
        }
        
        // POST create new user
        @PostMapping
        public User createUser(@RequestBody User user) {
            users.add(user);
            return user;
        }
        
        // PUT update user
        @PutMapping("/{id}")
        public User updateUser(@PathVariable Long id, @RequestBody User updatedUser) {
            User user = getUserById(id);
            if (user != null) {
                user.setName(updatedUser.getName());
                user.setEmail(updatedUser.getEmail());
            }
            return user;
        }
        
        // DELETE user
        @DeleteMapping("/{id}")
        public String deleteUser(@PathVariable Long id) {
            users.removeIf(u -> u.getId().equals(id));
            return "User deleted";
        }
    }
    
    Spring Boot Annotations Explained
    Annotation Purpose Example Use
    @RestController Marks class as REST API controller Handle HTTP requests
    @RequestMapping Base URL for all endpoints /api/users
    @GetMapping Handle GET requests Fetch data
    @PostMapping Handle POST requests Create new record
    @PutMapping Handle PUT requests Update existing record
    @DeleteMapping Handle DELETE requests Remove record
    @PathVariable Extract value from URL /users/{id}
    @RequestBody Parse JSON from request Receive user data
    Testing Your API

    Using Postman:

    • GET: http://localhost:8080/api/users - Fetch all users
    • POST: http://localhost:8080/api/users - Send JSON body
    • PUT: http://localhost:8080/api/users/1 - Update user with ID 1
    • DELETE: http://localhost:8080/api/users/1 - Delete user

    Database & SQL

    Why Databases Matter

    Every real application needs to store data permanently. Java connects to databases using JDBC, JPA, and Hibernate.

    Common Databases:

    • MySQL: Most popular open-source database.
    • PostgreSQL: Advanced features, JSON support.
    • H2: In-memory database for testing.
    • MongoDB: NoSQL database for JSON documents.
    SQL Basics You Must Know
    -- Create table
    CREATE TABLE users (
        id INT PRIMARY KEY AUTO_INCREMENT,
        name VARCHAR(100),
        email VARCHAR(100),
        age INT
    );
    
    -- Insert data
    INSERT INTO users (name, email, age) VALUES ('John Doe', '[email protected]', 25);
    
    -- Read data
    SELECT * FROM users;
    SELECT name, email FROM users WHERE age > 21;
    
    -- Update data
    UPDATE users SET age = 26 WHERE id = 1;
    
    -- Delete data
    DELETE FROM users WHERE id = 1;
    
    -- Joins
    SELECT orders.id, users.name 
    FROM orders 
    INNER JOIN users ON orders.user_id = users.id;
    
    JDBC Example
    import java.sql.*;
    
    public class DatabaseDemo {
        public static void main(String[] args) {
            String url = "jdbc:mysql://localhost:3306/mydb";
            String user = "root";
            String password = "password";
            
            try {
                // Connect to database
                Connection conn = DriverManager.getConnection(url, user, password);
                
                // Execute query
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT * FROM users");
                
                // Process results
                while (rs.next()) {
                    System.out.println(rs.getString("name"));
                }
                
                // Close connection
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    
    JPA and Hibernate

    Instead of writing SQL manually, JPA (Java Persistence API) lets you work with objects.

    import javax.persistence.*;
    
    @Entity
    @Table(name = "users")
    public class User {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;
        
        private String name;
        private String email;
        private int age;
        
        // Getters and setters
    }
    
    // Repository interface
    import org.springframework.data.jpa.repository.JpaRepository;
    
    public interface UserRepository extends JpaRepository {
        List findByName(String name);
        List findByAgeGreaterThan(int age);
    }
    
    // Usage in Service
    @Service
    public class UserService {
        @Autowired
        private UserRepository userRepository;
        
        public List getAllUsers() {
            return userRepository.findAll();
        }
        
        public User saveUser(User user) {
            return userRepository.save(user);
        }
    }
    

    Real-World Projects to Build

    Why Build Projects?

    Projects prove you can code. Recruiters want to see GitHub repos with working code, not just certificates.

    Goal: Build 3-5 projects that demonstrate different skills.

    Project 1: Todo List REST API

    Skills: Spring Boot, REST API, CRUD, MySQL

    Features:

    • Create, read, update, delete tasks
    • Mark tasks as complete/incomplete
    • Filter tasks by status (pending, completed)
    • Search tasks by title

    Tech Stack: Spring Boot + JPA + MySQL + Postman

    Timeline: 3-5 days

    Project 2: Employee Management System

    Skills: Full CRUD, Relationships, Validation

    Features:

    • Add, view, edit, delete employees
    • Department management
    • Employee-Department relationship (one-to-many)
    • Search and filter by department

    Tech Stack: Spring Boot + JPA + H2/MySQL

    Timeline: 5-7 days

    Project 3: E-Commerce Product API

    Skills: Authentication, Pagination, File Upload

    Features:

    • Product catalog with categories
    • User authentication (JWT)
    • Add to cart and checkout
    • Product image upload
    • Pagination and sorting

    Tech Stack: Spring Boot + Spring Security + JWT + PostgreSQL

    Timeline: 10-14 days

    Project 4: Blog Application

    Skills: Full-stack, Relationships, Comments

    Features:

    • User registration and login
    • Create, edit, delete blog posts
    • Comment on posts
    • Like/Unlike posts
    • User profiles

    Tech Stack: Spring Boot + React/Thymeleaf + MySQL

    Timeline: 14-21 days

    GitHub and Portfolio Tips
    • Create a GitHub account and push all projects
    • Write clear README files with setup instructions
    • Include screenshots and API documentation
    • Add a demo video or deployed link (Heroku, AWS)
    • Keep code clean: comments, naming conventions, formatting

    Interview Preparation

    Java Interview Roadmap

    Java interviews have 3 rounds:

    • Round 1: Phone screen (30 mins) - Basics, projects, availability.
    • Round 2: Technical (60-90 mins) - Coding problems, OOP, collections.
    • Round 3: System design (45-60 mins) - Architecture, scalability (for mid/senior).
    Top 20 Java Interview Questions

    1. What is Java? Why is it platform-independent?

    Java compiles to bytecode that runs on JVM (Java Virtual Machine). JVM is platform-specific but bytecode is universal.

    2. Difference between JDK, JRE, and JVM?

    • JDK: Development kit (compiler + libraries)
    • JRE: Runtime environment (JVM + libraries)
    • JVM: Executes bytecode

    3. What is OOP? Explain the 4 pillars.

    Encapsulation, Inheritance, Polymorphism, Abstraction (see OOP section above).

    4. Difference between == and .equals()?

    • == compares memory references
    • .equals() compares content/values

    5. What is a constructor?

    Special method called when creating an object. Same name as class, no return type.

    6. Difference between ArrayList and LinkedList?

    • ArrayList: Fast random access, slow add/remove in middle
    • LinkedList: Slow access, fast add/remove anywhere

    7. What is a HashMap? How does it work?

    Stores key-value pairs. Uses hashing to find values in O(1) time.

    8. Difference between interface and abstract class?

    • Interface: 100% abstract (before Java 8), can implement multiple
    • Abstract class: Can have concrete methods, single inheritance

    9. What is exception handling? Try-catch example.

    try {
        int result = 10 / 0;
    } catch (ArithmeticException e) {
        System.out.println("Cannot divide by zero");
    } finally {
        System.out.println("Always executes");
    }
    

    10. What is multithreading?

    Running multiple threads (tasks) concurrently. Use Thread class or Runnable interface.

    Coding Challenges Practice

    Easy Problems (Start Here):

    • Reverse a string
    • Find largest number in array
    • Check if number is prime
    • Count vowels in a string
    • Factorial using recursion

    Medium Problems:

    • Find duplicates in array
    • Two sum problem (LeetCode #1)
    • Valid parentheses (LeetCode #20)
    • Merge two sorted arrays
    • Find missing number in 1 to N

    Practice Platforms:

    • LeetCode (75-100 problems minimum)
    • HackerRank Java track
    • CodeSignal
    • InterviewBit
    Spring Boot Interview Questions

    1. What is Spring Boot? Why use it?

    Framework to build production-ready apps fast. Auto-configuration, embedded server, less boilerplate.

    2. Explain @RestController vs @Controller

    • @RestController: Returns JSON/XML (REST APIs)
    • @Controller: Returns HTML views

    3. What is Dependency Injection?

    Spring creates and manages objects (beans). Use @Autowired to inject dependencies.

    4. Difference between @Component, @Service, @Repository?

    • @Component: Generic bean
    • @Service: Business logic layer
    • @Repository: Data access layer

    5. How to handle exceptions globally?

    Use @ControllerAdvice and @ExceptionHandler.

    Behavioral Questions
    • Tell me about yourself (30-sec elevator pitch)
    • Why Java? Why this company?
    • Describe a challenging project
    • How do you handle tight deadlines?
    • Teamwork example
    • Where do you see yourself in 3 years?
    Interview Day Checklist
    • Test your mic, camera, internet 1 hour before
    • Have resume, projects, and portfolio links ready
    • Keep notepad for notes and whiteboard coding
    • Dress professionally (even for remote)
    • Ask 2-3 questions at the end (team, tech stack, growth)

    Learning Resources

    Free Courses & Tutorials
    • Java Basics: Codecademy Java course, Java Programming MOOC
    • Spring Boot: Spring.io guides, Amigoscode YouTube
    • Data Structures: freeCodeCamp, GeeksforGeeks
    • Projects: Java Brains, Programming with Mosh
    Books Worth Reading
    • Head First Java - Best for absolute beginners
    • Effective Java - Advanced patterns and best practices
    • Spring in Action - Deep dive into Spring framework
    • Clean Code - Write professional, maintainable code
    Community & Support
    • Stack Overflow - Ask coding questions
    • Reddit r/learnjava - Beginner-friendly community
    • Discord servers - Java, Spring Boot communities
    • LinkedIn - Connect with Java developers

    Java Developer Market Trends

    Salary Benchmarks (US Market 2024-2025)
    Level Experience Salary Range Key Skills
    Junior 0-2 years $70K - $85K Core Java, SQL, Git
    Mid-Level 3-5 years $95K - $125K Spring Boot, Microservices, REST APIs
    Senior 6-8 years $130K - $165K System Design, Cloud (AWS), Architecture
    Lead/Architect 9+ years $170K - $220K Team Leadership, Multi-cloud, FinOps

    Note: Salaries vary by location. SF/NYC +25%, remote -10%, healthcare/finance +$10K-$15K premium.

    Hot Skills in 2025
    • Spring Boot: Required in 95% of Java jobs
    • Microservices: Breaking monoliths into services
    • Cloud: AWS (Lambda, ECS), Azure, GCP
    • Docker & Kubernetes: Containerization and orchestration
    • Kafka: Event streaming for real-time data
    • GraphQL: Modern API alternative to REST
    Job Titles to Search
    • Java Developer
    • Backend Developer (Java)
    • Full Stack Java Developer
    • Spring Boot Developer
    • Java Software Engineer
    • Microservices Developer

    Frequently Asked Questions

    General Questions

    Can I learn Java with no programming experience?

    Yes. Java is beginner-friendly. Start with basics, practice daily, build projects. Most self-taught devs become job-ready in 12-16 weeks.

    Do I need a computer science degree?

    No. Many companies hire based on skills and projects. Build a strong GitHub portfolio and pass coding interviews.

    What's the fastest way to learn Java?

    Follow this path: 1) Java basics (4 weeks) β†’ 2) OOP & Collections (3 weeks) β†’ 3) Spring Boot (3 weeks) β†’ 4) Build 3 projects (4 weeks) β†’ 5) Interview prep (2 weeks).

    Java vs Python - which to learn first?

    Java for: Backend, enterprise, Android, higher salary. Python for: Data science, automation, AI/ML. Choose based on career goals.

    Is Java still relevant in 2025?

    Absolutely. Used by 90% of Fortune 500 companies. Banking, healthcare, e-commerce, government all run on Java.

    How long until I'm job-ready?

    12-16 weeks of focused learning (15-20 hours/week). Key milestones: basics β†’ OOP β†’ Spring Boot β†’ 3 projects β†’ interview prep.

    Best IDE for Java?

    IntelliJ IDEA (most popular), Eclipse (free), or VS Code with Java extensions.