Cloneable Interface in Java: clone(), Shallow and Deep Copy
Cloneable is a marker interface that allows Object.clone() to copy an instance. See shallow vs deep copy, a correct implementation and better alternatives.
2,887 posts about Java: questions with answers, tutorials and articles, newest first.
Cloneable is a marker interface that allows Object.clone() to copy an instance. See shallow vs deep copy, a correct implementation and better alternatives.
ObjectInputStream rebuilds Java objects from a serialized byte stream. See a full example, key methods, common exceptions and how to deserialize safely.
The transient keyword excludes a field from default Java serialization. See how values are restored, common use cases, and why native serialization is risky.
Implement Serializable and use ObjectOutputStream and ObjectInputStream to save and restore objects, with transient fields and deserialization safety.
Serializable is the Java marker interface that enables built-in object serialization. This guide covers serialVersionUID, transient fields, customisation and security.
How JavaBeans derives property names from getters and setters, why boolean and acronym names behave differently, and where records fit in.
A Java Bean is a class with a no-argument constructor, private fields and getters and setters. See a complete example and how it differs from records and Spring beans.
A Java Bean is a reusable class with a no-argument constructor, private fields and getters and setters. See examples, events, and records as an alternative.
ExecutorService manages thread pools, runs tasks, returns Future results and controls shutdown. See how to use it, including try-with-resources and virtual threads in Java 21.
A practical guide to CompletableFuture in Java: start async tasks, chain and combine results, handle exceptions, set timeouts and pick the right executor.
ForkJoinPool runs recursive CPU-bound tasks across cores using work stealing. See how it works, how to write tasks, and what to avoid.
Merge results of several asynchronous tasks with thenCombine, allOf and anyOf, and handle errors, timeouts and executors correctly.
CompletableFuture represents an async result you can chain, combine and recover from without blocking. Learn the core methods, executors and common mistakes.
Learn to create a CompletableFuture with supplyAsync and runAsync, choose an executor, chain stages, wait for several futures and handle exceptions.
Parallel streams split work across the common ForkJoinPool. See how they work, when they help, and which pitfalls to avoid with shared state, ordering and blocking.
The Java Stream API has intermediate operations such as filter and map, and terminal operations such as collect and reduce. See each one with runnable examples.
Java Streams do no work until a terminal operation runs. See how pipelines, short-circuiting and infinite streams make lazy evaluation efficient.
The Java Stream API processes sequences of elements with lazy, declarative pipelines. Learn operations, collectors, and parallel streams with runnable examples.
A functional interface has exactly one abstract method. Learn how to declare one, implement it with lambdas, and when to reuse the built-in types.
How to write functional-style Java: first-class functions, lambdas, streams, Optional, immutable records and modern pattern matching, with examples.