Free tutorial · 37 lessons
Java Tutorial
Learn Java 21 step by step: syntax, variables, strings, arrays, methods, classes, inheritance, interfaces, records, enums, collections, generics, lambdas, streams, exceptions and concurrency — every example shown with its output.
Java Basics
- Java Introduction — What Java is, where it's used and how Java programs run.
- Java Get Started — Install a JDK, then compile and run your first program.
- Java Syntax — Classes, the main method, statements, semicolons and braces.
- Java Output — Print text and numbers with println, print and printf.
- Java Comments — Single-line, multi-line and Javadoc comments.
- Java Variables — Declare typed variables, use var, final constants and naming rules.
- Java Data Types — The eight primitive types, wrapper classes and reference types.
- Java Type Casting — Widening and narrowing conversions, and parsing strings to numbers.
- Java Operators — Arithmetic, assignment, comparison, logical and ternary operators.
- Java Strings — Create strings, compare them, use common methods, text blocks and StringBuilder.
- Java Math — Math methods, rounding, random numbers and BigDecimal for money.
- Java History & Versions — How Java grew from a project for TV set-top boxes into one of the most used enterprise languages, every major release from 1.0 to Java 27 on one timeline, the LTS release model, and which version to use today.
Control Flow
- Java If Else — Make decisions with if, else if and else.
- Java Switch — Classic switch statements and modern switch expressions with arrows and patterns.
- Java Loops — while, do-while, for and for-each loops, with break and continue.
- Java Arrays — Create arrays, access elements, loop, sort and use 2D arrays.
Methods
- Java Methods — Define methods with parameters and return values, and overload them.
- Java Scope and Recursion — Where variables are visible, and methods that call themselves.
Object-Oriented Java
- Java Classes and Objects — Define classes with fields and methods, create objects and use constructors.
- Java Encapsulation and Modifiers — Access modifiers, getters and setters, static and final.
- Java Inheritance and Polymorphism — Extend classes, override methods, call super and use polymorphism.
- Java Abstract Classes and Interfaces — Define contracts with interfaces and partial implementations with abstract classes.
- Java Enums — Define a fixed set of constants with fields, methods and switch support.
- Java Records — Immutable data classes in one line with records (Java 16+).
Collections
- Java ArrayList — A resizable list: add, get, set, remove, loop and sort.
- Java HashMap — Store key-value pairs, count things and iterate over entries.
- Java HashSet — Store unique values and use set operations.
- Java Sorting and Comparators — Sort with Comparable, Comparator, and chained comparators.
Advanced Java
- Java Exceptions — try, catch, finally, try-with-resources and custom exceptions.
- Java Generics — Write type-safe classes and methods that work with any type.
- Java Lambdas — Lambda expressions, functional interfaces and method references.
- Java Streams — Process collections with filter, map, reduce, collect and groupingBy.
- Java Optional — Represent 'maybe a value' explicitly and avoid NullPointerException.
- Java Date and Time — Work with LocalDate, LocalDateTime, ZonedDateTime, Duration and formatting.
- Java File Handling — Read and write files with java.nio.file.Files and Path.
- Java Threads and Concurrency — Run work in parallel with executors, virtual threads and thread-safe counters.
Next Steps
- Java Next Steps — Spring Boot, build tools, testing and interview practice after the basics.