top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Externalizable in JAVA?

+1 vote
328 views
What is Externalizable in JAVA?
posted Mar 25, 2014 by Neeraj Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
 
Best answer

Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus if your class implements this interface, you can customize the serialization process by implementing these methods.

answer Mar 25, 2014 by Prachi Agarwal
+2 votes

Source : http://www.byteslounge.com/tutorials/java-externalizable-example
The Externalizable interface provides the necessary means for implementing a custom serialization mechanism. Implementing the Externalizable interface means that we must override some of its methods, namely the writeExternal and readExternal methods. These methods will be called when you serialize (or deserialize) a given instance. When we implement the Serializable interface we don't need to implement any method: The serialization takes place automatically. Even if we want to implement our own serialization mechanism by implementing the Serializable interface (yes it is also possible by defining writeObject and readObject methods) we don't need to override or implement any method. The JVM calls the serialization methods from our class using reflection. In early JVM implementations reflection performance was kind of slow so the Externalizable interface was also used to overcome this disadvantage.

answer Mar 28, 2014 by Harshita Dhaliwal
...