Skip to content

core-java

45 Posts

How to Create an Immutable Class in Java (Java 21)

Build an immutable Recipe class in Java 21: final class, final fields, defensive copies and with-ers, plus the leaks a final field alone lets through.

How Strings Are Used In Collections?

See how Java strings are used in collections: why they work so well as map keys and list values, and what to keep in mind when you store them in practice.

String, StringBuilder, and StringBuffer in Java

String, StringBuilder and StringBuffer in Java compared: mutability, thread safety and performance, and how to choose the right class for each situation.

Number Formatting in Java

Learn number formatting in Java: how to display numbers the way you want, including decimals, separators and alignment, with practical examples to follow.