ObjectStreamField 

Introduction

The Java.io.ObjectStreamField class is a description of a Serializable field from a Serializable class. An array of ObjectStreamFields is used to declare the Serializable fields of a class.

Class declaration

Following is the declaration for Java.io.ObjectStreamField class −

public class ObjectStreamField
   extends Object
      implements Comparable<Object>

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Class constructors

Sr.No.Constructor & Description
1ObjectStreamField(String name, Class<?> type)This creates a Serializable field with the specified type.
2ObjectStreamField(String name, Class<?> type, boolean unshared)This creates an ObjectStreamField representing a serializable field with the given name and type.

Class methods

Sr.No.Method & Description
1int compareTo(Object obj)This method compares this field with another ObjectStreamField.
2String getName()This method gets the name of this field.
3int getOffset()This method returns the offset of field within instance data.
4Class<?> getType()This method gets the type of the field.
5char getTypeCode()This method returns character encoding of field type.
6String getTypeString()This method returns the JVM type signature.
7boolean isPrimitive()This method returns true if this field has a primitive type.
8boolean isUnshared()This method returns boolean value indicating whether or not the serializable field represented by this ObjectStreamField instance is unshared.
9protected void setOffset(int offset)This method returns offset within instance data.
10String toString()This method returns a string that describes this field.

Methods inherited

This class inherits methods from the following classes −

  • Java.io.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *