Java ObjectStreamField class

A description of a Serializable field from a Serializable class. An array of ObjectStreamFields is used to declare the Serializable fields of a class.

The java.io.ObjectStreamClass.getField(String name) method gets the field of this class by name.

Constructor

ConstructorDescription
ObjectStreamField(String name, Class<?> type)It creates a Serializable field with the specified type.
ObjectStreamField(String name, Class<?> type, boolean unshared)It creates an ObjectStreamField representing a serializable field with the given name and type.

Methods

Modifier and TypeMethodDescription
intcompareTo(Object obj)It compares this field with another ObjectStreamField.
StringgetName()It gets the name of this field.
intGetOffset()Offset of field within instance data.
Class<?>getType()It get the type of the field.
chargetTypeCode()It returns character encoding of field type.
StringgetTypeString()It return the JVM type signature.
booleanisPrimitive()It return true if this field has a primitive type.
booleanisUnshared()It returns boolean value indicating whether or not the serializable field represented by this ObjectStreamField instance is unshared.
protected voidsetOffset(int offset)Offset within instance data.
StringtoString()It return a string that describes this field.

public char getTypeCode()

Returns character encoding of field type. The encoding is as follows:

Bbyte
Cchar
Ddouble
Ffloat
Iint
Jlong
Lclass or interface
Sshort
Zboolean
[array

Returns:

the typecode of the serializable field


Example:

Output:

I value
Z isTimeSet





Latest Courses