Java Cloning

Java HashMap

Clone a HashMap – Shallow and Deep Copy

Learn to create clone of a HashMap in Java. We will see the java programs to create shallow copy and deep copy of a HashMap. 1. Creating a Shallow Copy of Map We can create a shallow copy of a given HashMap in two ways. The first uses the clone() method, and the second is …

Java Deep Copy using In-memory Serialization

We all know that the easiest way of deep cloning (with some performance overhead) or deep copy is serialization. Java serialization involves serializing the object into bytes and from bytes to the object again. We suggest using in-memory deep cloning whenever it is the only need and we don’t need …

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.