Posts

Showing posts from October 21, 2010

Shallow Copy Deep Copy Java example

Shallow Copy Deep Copy  Java example Before knowing about Shallow Copy and Deep Copy you need to know about Clonable interface. Clonable interface -     Java has a clonable interface for make clone of any object.     Clonable Interface is a marker interface.     Clonable Interface has no method.     Class which implements Clonable interface, JVM give the permission for making the clone of         this class. Shallow Copy -              Clone can be archived by object.clone() method. It gives the Shallow copy of the object. In this process a new object is created That have all the value and instance variable. And if main object has any references to other object then the references are copied in the shallow copy. Example - class A implements Cloneable{         A(String personName, Integer age){  ...

Serialization In Java

Serialization In Java -  In java, serialization is the process for writing the state of object in sequence  of bytes stream. Serialization process for an object also called marshalling.  How to serialize an object?      Serializble is a marker interface, Through the implimantaion of Serializble interface  any object can be serialize.  There is no methods in Serializble interface, but Serializble interface tell to JVM  that Object can be written in byte stream.  If Serialized object have any transient variable . It means transient variable will not  written in to byte stream.   Example of Serialization -  class A implements Serializable{         A(String personName, Integer age){         this.personName=personName;         this.age=age;     }     private String personName = nul...

Recent Post

Recent Posts Widget