All About Class NotSerializableException in Java


An application that throws NotSerializableException indicates that the target object , that it tried to serialize,could not be serialized.This can happen to classes which does not implement Serializable interface. A class may implement Serializable interface but may refer or contain a non serializable object,in this case when we try to serialize the class,we will get NotSerializableException.

A subclass of a serializable class can prevent itself from being serialized by throwing this (NotSerializableException) exception from its writeObject() or readObject() methods.

It is a child class of ObjectSreamException.
The structure of the NotSerializableException class given as :

public class java.io.NotSerializableException extends java.io.ObjectStreamException{
//constructors:
public NotSerializableException();//default constructor
public NotSerializableException(String className);
}
 
All About Class NotSerializableException in Java All About Class NotSerializableException in Java Reviewed by Animesh Chatterjee on December 10, 2018 Rating: 5

No comments:

Powered by Blogger.