Java

Java Tutorial for Beginners: From Syntax to Spring Boot in 2026

14 min read Updated June 2026

Java remains one of the most hired stacks in Chennai's product and service companies. This tutorial takes you from your first println to a working REST API, with examples you can paste into IntelliJ and run today. There are no videos — read once, code along, revisit anytime.

01.Setting up your environment

You only need three things to start: a JDK (Java 21 LTS), an editor (IntelliJ IDEA Community is free), and a build tool. We'll use Maven because Spring Boot generates Maven projects by default.

On Linux or macOS, install via SDKMAN: `sdk install java 21-tem`. On Windows, download Temurin 21 from Adoptium and add `JAVA_HOME` to your environment variables.

$ java --version
openjdk 21.0.3 2024-04-16 LTS
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS)

02.Your first Java program

Every Java program starts inside a class. The JVM looks for a `public static void main(String[] args)` method as the entry point. Method signatures matter — change anything and the JVM won't recognize it.

public class Hello {
  public static void main(String[] args) {
    String name = args.length > 0 ? args[0] : "world";
    System.out.println("Hello, " + name);
  }
}

03.Object-oriented basics that actually matter at work

Most interview questions on OOP go beyond textbook definitions. Recruiters expect you to explain when to compose vs inherit, why immutability matters, and how `equals` + `hashCode` interact in a HashMap.

  • Prefer composition over inheritance — your future self will thank you.
  • Make value objects immutable with `record` (Java 16+).
  • Override `equals` and `hashCode` together, never one without the other.
  • Keep classes small and single-purpose — code review pain is proportional to file length.
public record Money(long amountMinor, String currency) {
  public Money plus(Money other) {
    if (!currency.equals(other.currency)) throw new IllegalArgumentException("currency mismatch");
    return new Money(amountMinor + other.amountMinor, currency);
  }
}

04.Collections and streams

Lists, Sets and Maps are the bread and butter of business logic. Pair them with the Streams API to write transformations that read like spec sheets.

var orders = List.of(new Order(1, 1200), new Order(2, 850), new Order(3, 1500));
long revenue = orders.stream()
    .filter(o -> o.amount() > 1000)
    .mapToLong(Order::amount)
    .sum();
System.out.println(revenue); // 2700

05.Your first Spring Boot REST API

Use https://start.spring.io to generate a project with the `Spring Web` dependency. Then create a controller. Spring Boot wires the server, serialization and routing in five lines of config.

@RestController
@RequestMapping("/api/quotes")
class QuoteController {
  private final List<String> quotes = List.of(
    "Talk is cheap. Show me the code.",
    "Simplicity is prerequisite for reliability."
  );

  @GetMapping("/{idx}")
  public String get(@PathVariable int idx) {
    return quotes.get(idx % quotes.size());
  }
}

06.What to learn next

Once this clicks, build a small REST + JPA + PostgreSQL project, add Spring Security with JWT, then deploy on a free Render or AWS tier. That portfolio + this fundamentals checklist is enough to clear most Chennai Java interviews.

  • Spring Data JPA with PostgreSQL
  • Bean validation + global error handling
  • Testing with JUnit 5 and Testcontainers
  • Docker + GitHub Actions CI

Take Java from tutorial to job offer.

Our Java programs come with projects, mentor reviews and 100% placement support.