Programming • Updated 8 November 2026

Java for Beginners in India: JDK Setup, Syntax, OOP, Collections, Exceptions, a First Project and Career Path

Learn Java basics: installing the JDK, writing your first program, data types, control flow, classes and objects, inheritance, interfaces, collections, exception handling, a small project and job paths in India.

JavaOOPJDKcollectionsbeginners
⏱ 5 min read

Java remains a mainstay of enterprise software, banking systems, Android development and large backend platforms, which makes it a dependable skill in the Indian job market. It is strongly typed and object-oriented, which teaches good habits. This guide covers the essentials with examples you can run.

Install the JDK

  1. Install a current LTS JDK (for example from Adoptium or Oracle).
  2. Verify with java -version and javac -version.
  3. Use an IDE such as IntelliJ IDEA Community or VS Code with Java extensions, or start with a text editor and the command line.

Hello, Java

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, India");
    }
}

Save as Hello.java, compile with javac Hello.java and run with java Hello. The class name must match the file name. Recent Java versions can also run single files directly with java Hello.java.

Types and variables

int age = 25;
double price = 199.99;
boolean active = true;
char grade = 'A';
String name = "Asha";
long population = 1_400_000_000L;
var city = "Pune";   // type inferred

Java has primitive types (int, double, boolean, char, long, etc.) and reference types such as String and arrays. Variables must be declared with a type, which catches many errors at compile time.

Control flow

for (int i = 1; i <= 5; i++) {
    if (i % 2 == 0) {
        System.out.println(i + " is even");
    } else {
        System.out.println(i + " is odd");
    }
}

String day = "MON";
switch (day) {
    case "MON" -> System.out.println("Start of week");
    case "FRI" -> System.out.println("Almost weekend");
    default -> System.out.println("Midweek");
}

Classes and objects

public class Account {
    private final String owner;
    private double balance;

    public Account(String owner, double opening) {
        this.owner = owner;
        this.balance = opening;
    }

    public void deposit(double amount) {
        if (amount <= 0) throw new IllegalArgumentException("Amount must be positive");
        balance += amount;
    }

    public double getBalance() { return balance; }
}

// usage
Account a = new Account("Ravi", 5000);
a.deposit(1500);
System.out.println(a.getBalance());

Encapsulation means hiding fields (private) and exposing behaviour through methods. Constructors set up new objects.

Inheritance, interfaces and polymorphism

interface Shape { double area(); }

class Circle implements Shape {
    double r;
    Circle(double r) { this.r = r; }
    public double area() { return Math.PI * r * r; }
}

class Rect implements Shape {
    double w, h;
    Rect(double w, double h) { this.w = w; this.h = h; }
    public double area() { return w * h; }
}

List<Shape> shapes = List.of(new Circle(2), new Rect(3, 4));
for (Shape s : shapes) System.out.println(s.area());

The four pillars of OOP are encapsulation, abstraction, inheritance and polymorphism. Prefer composition and interfaces over deep inheritance trees.

Collections

import java.util.*;

List<String> names = new ArrayList<>();
names.add("Asha"); names.add("Ravi");
Map<String, Integer> marks = new HashMap<>();
marks.put("Asha", 91);
Set<String> unique = new HashSet<>(names);

names.stream().filter(n -> n.startsWith("A")).forEach(System.out::println);

Know ArrayList, LinkedList, HashMap, TreeMap, HashSet and the Stream API. Interviewers in India commonly ask about collections internals, such as how HashMap works.

Exceptions

try {
    int x = Integer.parseInt("abc");
} catch (NumberFormatException e) {
    System.out.println("Invalid number: " + e.getMessage());
} finally {
    System.out.println("Done");
}

Checked exceptions must be declared or handled, and unchecked ones (RuntimeException) represent programming errors. Use try-with-resources to close files and connections automatically.

A small project

Build a command-line library or bank app: classes for Book or Account, a list to store items, a menu loop with Scanner, and file saving. Then add unit tests with JUnit and move to a build tool such as Maven or Gradle.

Where Java takes you

  • Backend development with Spring Boot, the most in-demand Java framework.
  • Android development, now often in Kotlin but with Java foundations.
  • Enterprise, banking and insurance systems.
  • Big data tools and test automation with Selenium.

Learn SQL alongside Java, practise data structures, and look at career change tips and internship advice. Compare with Python to decide what suits you.

Common beginner mistakes

  • Comparing strings with == instead of .equals().
  • Ignoring null checks.
  • Putting everything in main.
  • Catching exceptions and doing nothing.
  • Skipping practice problems on arrays, strings and recursion.

How to study Java for jobs

Split your time between language fundamentals, data structures and projects. In the first month, finish syntax, OOP and collections, solving one or two small problems daily on arrays, strings and recursion. In the second, learn the Stream API, generics, file handling and unit tests, and study how HashMap and ArrayList work internally because interviewers love those questions. In the third, build a Spring Boot REST API with a database, deploy it, and describe the design on your resume. Read other people's code, learn Git, and practise explaining your solutions aloud. Campus placements and entry-level service-company roles usually test core Java, SQL, aptitude and basic problem solving, while product companies expect stronger algorithms.

Frequently asked questions

Is Java still worth learning?

Yes, it is widely used in enterprise and backend roles.

What is the difference between JDK, JRE and JVM?

The JDK is the development kit, the JRE runs programs, and the JVM executes bytecode.

Java or Python first?

Python is easier to start, Java teaches strict typing and OOP well.

What is Spring Boot?

A popular Java framework for building web services quickly.

How do I compare strings in Java?

Use equals() instead of ==.

Which IDE is best?

IntelliJ IDEA Community Edition is a popular choice.

Last reviewed 8 November 2026. Rates, limits and rules change, so confirm figures with the official source before you act.

Keep reading

Information on AMTools is for general guidance and is not professional financial, tax, legal or medical advice. Rules, rates and limits change, so check the latest official source before acting.