modern-java
8 tutorials tagged “modern-java”.
- Flexible Constructor BodiesJava 25 lets constructors run code before super(...) or this(...): validating arguments first, preparing values, and what is still forbidden.
- Compact Source Files and Instance Main MethodsJava 25 lets you write a program as just void main() { ... } with the IO class for input and output. What it removes, what it adds, and when to use it.
- Simple Console I/O with the IO ClassJava 25's java.lang.IO class: println, print and readln for quick console programs without System.out or Scanner, what readln returns, and when to use it.
- Local Variable Type InferenceHow var lets the compiler work out a local variable's type, where you can and can't use it, the diamond trap, and when var makes code clearer or worse.
- Java Versions and Release CycleHow Java versions are numbered, why a new version comes out every six months, and what LTS means for the version you should use.
- JDK DistributionsWhy there are many JDKs (Oracle JDK, Eclipse Temurin, Amazon Corretto and more), how they differ, and which one to install.
- Running a Single Source File DirectlyRun a .java file in one step with java File.java, use other source files in the same folder (Java 22+), and turn a Java file into a script on macOS and Linux.
- Switch ExpressionsThe modern switch that produces a value: arrow syntax, several labels per case, yield for multi-line cases, and exhaustiveness checks.