37 tutorials
Java tutorials
Every Java guide on the site, newest first. Each one is built around code you can run.
Java has changed more in the last decade than in the two before it. Records, sealed types, pattern matching in switch, virtual threads and a six-month release cadence have all landed since Java 8, and a great deal of material written for the language still assumes none of them exist. The guides collected here state the release they were written against, because on this subject that is the difference between working code and a compile error.
The coverage falls into three groups. The first is the standard library as you actually use it: collections and their performance characteristics, streams, Optional, the java.time API that replaced Date and Calendar, and string handling. The second is concurrency — threads, executors, CompletableFuture, the memory model, and the parts of java.util.concurrent that exist so you do not have to write them. The third is the language itself, including the features that make older idioms unnecessary.
Every article shows complete, compilable files rather than fragments. Where behaviour is easier to see than to describe, the guide prints output rather than asserting what would happen — which for anything involving threads is the only way to make the point stick.
Two areas get more space than their share of the language, because they cause more trouble than their share of the language. Collections is the first: the difference between ArrayList and LinkedList is not academic when a list is iterated in a loop, HashMap behaviour depends on equals and hashCode being written as a pair, and the concurrent collections exist for reasons worth understanding before reaching for one. The second is date and time, where the pre-Java-8 classes are mutable, not thread-safe, and still turn up in code being written today.
Where a modern feature makes an older idiom unnecessary, the article says so directly. A guide that teaches SimpleDateFormat without mentioning that DateTimeFormatter replaced it, or that shows anonymous inner classes where a lambda now fits, is teaching something you will have to unlearn.
If you are working through this section rather than arriving from a search, the order that works is language first, then collections, then concurrency. Each layer assumes the one before it, and concurrency in particular is much harder to reason about without a clear picture of how objects and references behave.
All Java tutorials
- Java CompletableFuture Tutorial with Runnable Examples Java · 22 min
- Java Concurrency Issues and Thread Synchronization Java · 14 min
- Java Callable and Future Tutorial Java · 12 min
- Java ExecutorService and Thread Pool Tutorial Java · 12 min
- How to Format Date and Time in Java Java · 13 min
- Add or Subtract Days and Hours from a Date in Java Java · 13 min
- How to Create a New File in Java Java · 13 min
- How to Get the Current Date and Time in Java Java · 12 min
- How to Get the Current Epoch Timestamp in Java Java · 13 min
- How to Read a File in Java Java · 13 min
- How to Compare Date and Time in Java Java · 12 min
- How to Parse a String to a Date in Java Java · 11 min
- How to Check if a File or Directory Exists in Java Java · 13 min
- How to Copy a File or Directory in Java Java · 13 min
- How to Delete a File or Directory in Java Java · 13 min
- How to Move or Rename a File in Java Java · 13 min
- How to Create a Temp File or Directory in Java Java · 13 min
- Java Singleton Design Pattern Example Java · 14 min
- SimpleDateFormat and Thread Safety in Java Java · 11 min
- Java Comparable and Comparator Interface Examples Java · 12 min
- Java PriorityQueue Tutorial with Examples Java · 13 min
- Java Queue and Deque Tutorial with Examples Java · 12 min
- Java Stack Class Tutorial with Examples Java · 12 min
- Java TreeMap: The Complete Reference Java · 14 min
- Java HashSet Tutorial with Examples Java · 11 min
- Java HashMap Tutorial with Examples Java · 13 min
- Java ArrayList Tutorial with Examples Java · 13 min
- How to Write an Excel File in Java with Apache POI Java · 13 min
- Reading and Writing Excel Files in Java with Apache POI Java · 12 min
- Read and Write CSV in Java with Commons CSV Java · 13 min
- Read and Write CSV in Java with OpenCSV Java · 13 min
- Introduction to Java 8 Lambda Expressions Java · 14 min
- Java Locks and Atomic Variables Tutorial Java · 13 min
- Java Thread and Runnable Tutorial Java · 13 min
- Java Concurrency and Multithreading Basics Java · 12 min
- Generate a QR Code in Java Using ZXing Java · 12 min
- Java Optional Tutorial with Examples Java · 12 min
Frequently asked questions
Which Java version do these tutorials target?
Each article names its version. Anything written against a specific release says so at the top, and where a feature arrived later than Java 8 that is called out inline.
Do I need an IDE to follow along?
No. Every example builds with Maven or Gradle from the command line, and the commands are shown.
Where should I start with concurrency?
Threads and the executor framework first, then CompletableFuture for composing asynchronous work. The memory model makes far more sense once you have written something that races.
Are these suitable for interview preparation?
The algorithms and collections material overlaps heavily with interview topics, and there is a dedicated interview section.
Are records, sealed types and pattern matching covered?
Yes, alongside the older constructions they replace, so it is clear what the newer feature is for.
Why so much attention to equals and hashCode?
Because HashMap and HashSet behaviour depends on them being consistent, and a mismatched pair produces a bug that looks like data loss rather than a contract violation.