Serialization

Rule 5:For instance control, prefer enum types to readResolve

Instance Control : singleton class
public class Elvis {
public static final Elvis INSTANCE = new Elvis();
private Elvis() { … }
public void leaveTheBuilding() { … }
}
Above class would no longer be a singleton if the words implements Serializable were added to its declaration.

readResolve and enum are the ways to control instance

Published by

Unknown's avatar

sevanand yadav

software engineer working as web developer having specialization in spring MVC with mysql,hibernate

Leave a comment