Home » Java ObjectInputStream defaultReadObject() Method with Examples

Java ObjectInputStream defaultReadObject() Method with Examples

by Online Tutorials Library

Java ObjectInputStream defaultReadObject() Method

The defaultReadObject() method of ObjectInputStream class is used to read the non-static and non-transient fields of the current class from this stream, i.e, one cannot use defaultReadObject() to read the static fields. This may only be called from the readObject method of the class being desterilized. You cannot use defaultReadObject() directly.

Syntax

Parameter

No parameter is passed.

Returns

The return type is void.

Throws

NotActiveException , ClassNotFoundException , IOException.

Example 1

Output:

string that is in task class : TutorAspire 

Example 2

Output:

[email protected]  string that is in task class  : TutorAspire 

You may also like