Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/io/ObjectStreamField#pubctors) \| [Methods](https://developer.android.com/reference/java/io/ObjectStreamField#pubmethods) \| [Protected Methods](https://developer.android.com/reference/java/io/ObjectStreamField#promethods) \| [Inherited Methods](https://developer.android.com/reference/java/io/ObjectStreamField#inhmethods)

# ObjectStreamField

` public class ObjectStreamField `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/java/lang/Object> `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.io.ObjectStreamField |

<br />

*** ** * ** ***

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

- `https://developer.android.com/reference/java/io/ObjectStreamClass`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/io/ObjectStreamField#ObjectStreamField(java.lang.String,%20java.lang.Class<?>)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/lang/Class<?> type) ` Create a Serializable field with the specified type. |
| ` https://developer.android.com/reference/java/io/ObjectStreamField#ObjectStreamField(java.lang.String,%20java.lang.Class<?>,%20boolean)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/lang/Class<?> type, boolean unshared) ` Creates an ObjectStreamField representing a serializable field with the given name and type. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/java/io/ObjectStreamField#compareTo(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Compare this field with another `ObjectStreamField`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/io/ObjectStreamField#getName()() ` Get the name of this field. |
| ` int` | ` https://developer.android.com/reference/java/io/ObjectStreamField#getOffset()() ` Offset of field within instance data. |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/io/ObjectStreamField#getType()() ` Get the type of the field. |
| ` char` | ` https://developer.android.com/reference/java/io/ObjectStreamField#getTypeCode()() ` Returns character encoding of field type. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/io/ObjectStreamField#getTypeString()() ` Return the JVM type signature. |
| ` boolean` | ` https://developer.android.com/reference/java/io/ObjectStreamField#isPrimitive()() ` Return true if this field has a primitive type. |
| ` boolean` | ` https://developer.android.com/reference/java/io/ObjectStreamField#isUnshared()() ` Returns boolean value indicating whether or not the serializable field represented by this ObjectStreamField instance is unshared. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/io/ObjectStreamField#toString()() ` Return a string that describes this field. |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/java/io/ObjectStreamField#setOffset(int)(int offset) ` Offset within instance data. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/lang/Comparable ` ` abstract int` ` https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/java/lang/Object o) `

Compares this object with the specified object for order.

## Public constructors

### ObjectStreamField

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ObjectStreamField (String name, 
                Class<?> type)
```

Create a Serializable field with the specified type. This field should be documented with a `serialField` tag.

<br />

| Parameters ||
|---|---|
| `name` | `String`: the name of the serializable field <br /> |
| `type` | `Class`: the `Class` object of the serializable field <br /> |

### ObjectStreamField

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ObjectStreamField (String name, 
                Class<?> type, 
                boolean unshared)
```

Creates an ObjectStreamField representing a serializable field with the given name and type. If unshared is false, values of the represented field are serialized and deserialized in the default manner--if the field is non-primitive, object values are serialized and deserialized as if they had been written and read by calls to writeObject and readObject. If unshared is true, values of the represented field are serialized and deserialized as if they had been written and read by calls to writeUnshared and readUnshared.

<br />

| Parameters ||
|---|---|
| `name` | `String`: field name <br /> |
| `type` | `Class`: field type <br /> |
| `unshared` | `boolean`: if false, write/read field values in the same manner as writeObject/readObject; if true, write/read in the same manner as writeUnshared/readUnshared <br /> |

## Public methods

### compareTo

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (Object obj)
```

Compare this field with another `ObjectStreamField`. Return -1 if this is smaller, 0 if equal, 1 if greater. Types that are primitives are "smaller" than object types. If equal, the field names are compared.

<br />

| Parameters ||
|---|---|
| `obj` | `Object` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getName

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getName ()
```

Get the name of this field.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a `String` representing the name of the serializable field <br /> |

### getOffset

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getOffset ()
```

Offset of field within instance data.

<br />

| Returns ||
|---|---|
| `int` | the offset of this field <br /> |

**See also:**

- `https://developer.android.com/reference/java/io/ObjectStreamField#setOffset(int)`

### getType

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class<?> getType ()
```

Get the type of the field. If the type is non-primitive and this `ObjectStreamField` was obtained from a deserialized `https://developer.android.com/reference/java/io/ObjectStreamClass` instance, then `Object.class` is returned. Otherwise, the `Class` object for the type of the field is returned.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | a `Class` object representing the type of the serializable field <br /> |

### getTypeCode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public char getTypeCode ()
```

Returns character encoding of field type. The encoding is as follows:
>
> ```
> B            byte
> C            char
> D            double
> F            float
> I            int
> J            long
> L            class or interface
> S            short
> Z            boolean
> [            array
> ```

<br />

<br />

| Returns ||
|---|---|
| `char` | the typecode of the serializable field <br /> |

### getTypeString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getTypeString ()
```

Return the JVM type signature.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | null if this field has a primitive type. <br /> |

### isPrimitive

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isPrimitive ()
```

Return true if this field has a primitive type.

<br />

| Returns ||
|---|---|
| `boolean` | true if and only if this field corresponds to a primitive type <br /> |

### isUnshared

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUnshared ()
```

Returns boolean value indicating whether or not the serializable field represented by this ObjectStreamField instance is unshared.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this field is unshared <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Return a string that describes this field.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

## Protected methods

### setOffset

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void setOffset (int offset)
```

Offset within instance data.

<br />

| Parameters ||
|---|---|
| `offset` | `int`: the offset of the field <br /> |

**See also:**

- `https://developer.android.com/reference/java/io/ObjectStreamField#getOffset()`