Java tutorial

Learn Java basics and build reliable object-oriented applications.

Start the course

Course contents

Getting Started

  1. Introduction to Java — Learn what Java is, where it came from, the JVM, JRE and JDK, how to install Java, and how a Java program is written, compiled and run.
  2. Variables and Data Types — Create variables and constants, choose between Java's primitive and non-primitive types, read input with Scanner, and convert between types with casting, parse methods and String.valueOf.
  3. Operators — Use Java's arithmetic, increment, comparison, logical, assignment, ternary, bitwise and shift operators, and learn the order Java follows to evaluate an expression.

Control Flow

  1. Conditional Statements — Make decisions in Java with if, if-else, else-if ladders, nested conditions, combined conditions, the ternary operator and switch.
  2. Loops — Repeat code with for, while and do-while loops, nest loops, control them with break and continue, and avoid infinite loops.
  3. Methods — Write and call Java methods with parameters and return values, overload them, use static and instance methods, varargs and recursion, and see how pass by value works.

Reference Types

  1. Arrays — Store many values in one array, read and update elements, loop with for and for-each, build 2D and jagged arrays, and sort, search, fill and copy with the Arrays class.
  2. Strings — Work with Java text: immutability, the String Pool, literals and text blocks, formatting, common String methods, comparing strings, and building text with StringBuilder and StringBuffer.
  3. DateTime — Handle dates and times with LocalDate, LocalTime, LocalDateTime and ZonedDateTime, format and parse them, do date arithmetic, and measure gaps with Duration and Period.

Object-Oriented Programming

  1. Classes and Objects — Create your own types with classes, make objects with new, use fields, methods, this and constructors, control access with modifiers, and see objects on the stack and heap.
  2. Static Members — Share data and behaviour across a whole class with static variables, static methods and static blocks, and learn why main is static.
  3. Advanced Classes — Organise code with static nested, inner, local and anonymous classes, and control extension with final and sealed classes.
  4. Enums and Records — Model fixed sets of choices with enums, including fields, constructors and methods, and carry immutable data with records.
  5. Interfaces — Describe abilities with interfaces: declare and implement them, implement several at once, add default and static methods, and use functional interfaces with lambdas.
  6. Inheritance — Reuse code with inheritance: parent and child classes, the IS-A test, types of inheritance, extends, super and constructor chaining.
  7. Polymorphism — Use one name for many behaviours with overloading and overriding, @Override, dynamic method dispatch, and safe upcasting and downcasting.
  8. Abstraction — Hide details and show only what matters with abstract classes, abstract methods and interfaces, and choose between them.
  9. Encapsulation — Protect object data with private fields, getters and setters, validation and read-only patterns, and see how encapsulation differs from data hiding.

Exception Handling

  1. Exception Handling — Handle problems while a program runs: errors vs exceptions, checked vs unchecked, try, catch and finally, throw and throws, custom exceptions and propagation.

Packages and Access Control

  1. Packages — Organise classes into packages: declare and import them, use built-in packages, build custom packages, control access across packages, and use static import.

Generics

  1. Generics Fundamentals — Write type-safe, reusable code with generic classes, methods and interfaces, bounded type parameters, wildcards, and generic collections.

Collections Framework

  1. Collections Fundamentals — See why collections beat arrays, how List, Set and Map fit into the Collections Framework, how to choose between them, and how to loop with for-each and Iterator.
  2. ArrayList — Use ArrayList to add, remove, read, update, search, sort and loop through a resizable list, and understand capacity vs size.
  3. Set and Map — Store key-value pairs with HashMap and unique items with HashSet, loop through them, use set operations, and compare them with Hashtable and TreeSet.
  4. Linear Data Structures — Use stacks (LIFO) and queues (FIFO): push, pop and peek, Queue with LinkedList and PriorityQueue, offer vs add, poll vs remove, and real applications.

Functional Programming

  1. Lambda Expressions — Write short, nameless functions with lambdas, use them with functional interfaces like Predicate, Function, Consumer and Supplier, and shorten them with method references.
  2. Streams — Process collections with streams: create them, chain filter, map, sorted and more, finish with collect, reduce, count and match operations, and use parallel streams.

File Handling

  1. File Handling — Read, write and append files with Files, BufferedReader and BufferedWriter, handle bytes with file streams, save objects with serialization, and manage files with try-with-resources.

Multithreading

  1. Introduction to Threads — Learn processes vs threads, the thread lifecycle, creating threads with Thread and Runnable, and using start, run, sleep, join and priorities.
  2. Synchronization — Keep shared data correct across threads: race conditions, thread safety, synchronized methods and blocks, and how to avoid deadlocks.

Modern Java Features

  1. Optional — Handle missing values safely with Optional: create one with of, ofNullable and empty, then use isPresent, ifPresent, orElse and orElseGet.
  2. Pattern Matching — Check a value's type and use it in one step with pattern matching for instanceof and switch, including guards, null cases and record patterns.

Reference

  1. Cheat Sheet — Every topic in the Java course on one page: syntax, the methods used most, and the mistakes that cost the most time.