Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/util/Objects#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/Objects#inhmethods)

# Objects


`
public

final

class
Objects
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

This class consists of `static` utility methods for operating
on objects, or checking certain conditions before operation. These utilities
include `null`-safe or `null`-tolerant methods for computing the
hash code of an object, returning a string for an object, comparing two
objects, and checking if indexes or sub-range values are out of bounds.

## Summary

| ### Public methods ||
|---|---|
| ` static long` | ` https://developer.android.com/reference/java/util/Objects#checkFromIndexSize(long,%20long,%20long)(long fromIndex, long size, long length) ` Checks if the sub-range from `fromIndex` (inclusive) to `fromIndex + size` (exclusive) is within the bounds of range from `0` (inclusive) to `length` (exclusive). |
| ` static int` | ` https://developer.android.com/reference/java/util/Objects#checkFromIndexSize(int,%20int,%20int)(int fromIndex, int size, int length) ` Checks if the sub-range from `fromIndex` (inclusive) to `fromIndex + size` (exclusive) is within the bounds of range from `0` (inclusive) to `length` (exclusive). |
| ` static int` | ` https://developer.android.com/reference/java/util/Objects#checkFromToIndex(int,%20int,%20int)(int fromIndex, int toIndex, int length) ` Checks if the sub-range from `fromIndex` (inclusive) to `toIndex` (exclusive) is within the bounds of range from `0` (inclusive) to `length` (exclusive). |
| ` static long` | ` https://developer.android.com/reference/java/util/Objects#checkFromToIndex(long,%20long,%20long)(long fromIndex, long toIndex, long length) ` Checks if the sub-range from `fromIndex` (inclusive) to `toIndex` (exclusive) is within the bounds of range from `0` (inclusive) to `length` (exclusive). |
| ` static long` | ` https://developer.android.com/reference/java/util/Objects#checkIndex(long,%20long)(long index, long length) ` Checks if the `index` is within the bounds of the range from `0` (inclusive) to `length` (exclusive). |
| ` static int` | ` https://developer.android.com/reference/java/util/Objects#checkIndex(int,%20int)(int index, int length) ` Checks if the `index` is within the bounds of the range from `0` (inclusive) to `length` (exclusive). |
| ` static <T> int` | ` https://developer.android.com/reference/java/util/Objects#compare(T,%20T,%20java.util.Comparator<?%20super%20T>)(T a, T b, https://developer.android.com/reference/java/util/Comparator<? super T> c) ` Consequently, if both arguments are `null` 0 is returned. |
| ` static boolean` | ` https://developer.android.com/reference/java/util/Objects#deepEquals(java.lang.Object,%20java.lang.Object)(https://developer.android.com/reference/java/lang/Object a, https://developer.android.com/reference/java/lang/Object b) ` Two `null` values are deeply equal. |
| ` static boolean` | ` https://developer.android.com/reference/java/util/Objects#equals(java.lang.Object,%20java.lang.Object)(https://developer.android.com/reference/java/lang/Object a, https://developer.android.com/reference/java/lang/Object b) ` Consequently, if both arguments are `null`, `true` is returned. |
| ` static int` | ` https://developer.android.com/reference/java/util/Objects#hash(java.lang.Object[])(https://developer.android.com/reference/java/lang/Object values) ` The hash code is generated as if all the input values were placed into an array, and that array were hashed by calling `https://developer.android.com/reference/java/util/Arrays#hashCode(java.lang.Object[])`. |
| ` static int` | ` https://developer.android.com/reference/java/util/Objects#hashCode(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` |
| ` static boolean` | ` https://developer.android.com/reference/java/util/Objects#isNull(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` |
| ` static boolean` | ` https://developer.android.com/reference/java/util/Objects#nonNull(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` |
| ` static <T> T` | ` https://developer.android.com/reference/java/util/Objects#requireNonNull(T,%20java.lang.String)(T obj, https://developer.android.com/reference/java/lang/String message) ` Checks that the specified object reference is not `null` and throws a customized `https://developer.android.com/reference/java/lang/NullPointerException` if it is. |
| ` static <T> T` | ` https://developer.android.com/reference/java/util/Objects#requireNonNull(T,%20java.util.function.Supplier<java.lang.String>)(T obj, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/java/lang/String> messageSupplier) ` Checks that the specified object reference is not `null` and throws a customized `https://developer.android.com/reference/java/lang/NullPointerException` if it is. |
| ` static <T> T` | ` https://developer.android.com/reference/java/util/Objects#requireNonNull(T)(T obj) ` Checks that the specified object reference is not `null`. |
| ` static <T> T` | ` https://developer.android.com/reference/java/util/Objects#requireNonNullElse(T,%20T)(T obj, T defaultObj) ` |
| ` static <T> T` | ` https://developer.android.com/reference/java/util/Objects#requireNonNullElseGet(T,%20java.util.function.Supplier<?%20extends%20T>)(T obj, https://developer.android.com/reference/java/util/function/Supplier<? extends T> supplier) ` |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/util/Objects#toIdentityString(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/util/Objects#toString(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/util/Objects#toString(java.lang.Object,%20java.lang.String)(https://developer.android.com/reference/java/lang/Object o, https://developer.android.com/reference/java/lang/String nullDefault) ` |

| ### 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*. | ||

## Public methods

### checkFromIndexSize

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

```
public static long checkFromIndexSize (long fromIndex, 
                long size, 
                long length)
```

Checks if the sub-range from `fromIndex` (inclusive) to
`fromIndex + size` (exclusive) is within the bounds of range from
`0` (inclusive) to `length` (exclusive).

The sub-range is defined to be out of bounds if any of the following
inequalities is true:

- `fromIndex < 0`
- `size < 0`
- `fromIndex + size > length`, taking into account integer overflow
- `length < 0`, which is implied from the former inequalities

<br />

<br />

| Parameters ||
|---|---|
| `fromIndex` | `long`: the lower-bound (inclusive) of the sub-interval <br /> |
| `size` | `long`: the size of the sub-range <br /> |
| `length` | `long`: the upper-bound (exclusive) of the range <br /> |

| Returns ||
|---|---|
| `long` | `fromIndex` if the sub-range within bounds of the range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the sub-range is out of bounds |

### checkFromIndexSize

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

```
public static int checkFromIndexSize (int fromIndex, 
                int size, 
                int length)
```

Checks if the sub-range from `fromIndex` (inclusive) to
`fromIndex + size` (exclusive) is within the bounds of range from
`0` (inclusive) to `length` (exclusive).

The sub-range is defined to be out of bounds if any of the following
inequalities is true:

- `fromIndex < 0`
- `size < 0`
- `fromIndex + size > length`, taking into account integer overflow
- `length < 0`, which is implied from the former inequalities

<br />

<br />

| Parameters ||
|---|---|
| `fromIndex` | `int`: the lower-bound (inclusive) of the sub-interval <br /> |
| `size` | `int`: the size of the sub-range <br /> |
| `length` | `int`: the upper-bound (exclusive) of the range <br /> |

| Returns ||
|---|---|
| `int` | `fromIndex` if the sub-range within bounds of the range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the sub-range is out of bounds |

### checkFromToIndex

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

```
public static int checkFromToIndex (int fromIndex, 
                int toIndex, 
                int length)
```

Checks if the sub-range from `fromIndex` (inclusive) to
`toIndex` (exclusive) is within the bounds of range from `0`
(inclusive) to `length` (exclusive).

The sub-range is defined to be out of bounds if any of the following
inequalities is true:

- `fromIndex < 0`
- `fromIndex > toIndex`
- `toIndex > length`
- `length < 0`, which is implied from the former inequalities

<br />

<br />

| Parameters ||
|---|---|
| `fromIndex` | `int`: the lower-bound (inclusive) of the sub-range <br /> |
| `toIndex` | `int`: the upper-bound (exclusive) of the sub-range <br /> |
| `length` | `int`: the upper-bound (exclusive) the range <br /> |

| Returns ||
|---|---|
| `int` | `fromIndex` if the sub-range within bounds of the range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the sub-range is out of bounds |

### checkFromToIndex

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

```
public static long checkFromToIndex (long fromIndex, 
                long toIndex, 
                long length)
```

Checks if the sub-range from `fromIndex` (inclusive) to
`toIndex` (exclusive) is within the bounds of range from `0`
(inclusive) to `length` (exclusive).

The sub-range is defined to be out of bounds if any of the following
inequalities is true:

- `fromIndex < 0`
- `fromIndex > toIndex`
- `toIndex > length`
- `length < 0`, which is implied from the former inequalities

<br />

<br />

| Parameters ||
|---|---|
| `fromIndex` | `long`: the lower-bound (inclusive) of the sub-range <br /> |
| `toIndex` | `long`: the upper-bound (exclusive) of the sub-range <br /> |
| `length` | `long`: the upper-bound (exclusive) the range <br /> |

| Returns ||
|---|---|
| `long` | `fromIndex` if the sub-range within bounds of the range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the sub-range is out of bounds |

### checkIndex

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

```
public static long checkIndex (long index, 
                long length)
```

Checks if the `index` is within the bounds of the range from
`0` (inclusive) to `length` (exclusive).

The `index` is defined to be out of bounds if any of the
following inequalities is true:

- `index < 0`
- `index >= length`
- `length < 0`, which is implied from the former inequalities

<br />

<br />

| Parameters ||
|---|---|
| `index` | `long`: the index <br /> |
| `length` | `long`: the upper-bound (exclusive) of the range <br /> |

| Returns ||
|---|---|
| `long` | `index` if it is within bounds of the range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the `index` is out of bounds |

### checkIndex

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

```
public static int checkIndex (int index, 
                int length)
```

Checks if the `index` is within the bounds of the range from
`0` (inclusive) to `length` (exclusive).

The `index` is defined to be out of bounds if any of the
following inequalities is true:

- `index < 0`
- `index >= length`
- `length < 0`, which is implied from the former inequalities

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index <br /> |
| `length` | `int`: the upper-bound (exclusive) of the range <br /> |

| Returns ||
|---|---|
| `int` | `index` if it is within bounds of the range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the `index` is out of bounds |

### compare

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

```
public static int compare (T a, 
                T b, 
                Comparator<? super T> c)
```


Consequently, if both arguments are `null` 0
is returned.

Note that if one of the arguments is `null`, a `NullPointerException` may or may not be thrown depending on
what ordering policy, if any, the `https://developer.android.com/reference/java/util/Comparator`
chooses to have for `null` values.

<br />

| Parameters ||
|---|---|
| `a` | `T`: an object <br /> |
| `b` | `T`: an object to be compared with `a` <br /> |
| `c` | `Comparator`: the `Comparator` to compare the first two arguments <br /> |

| Returns ||
|---|---|
| `int` | 0 if the arguments are identical and `c.compare(a, b)` otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Comparable`
- `https://developer.android.com/reference/java/util/Comparator`

### deepEquals

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

```
public static boolean deepEquals (Object a, 
                Object b)
```


Two `null` values are deeply equal. If both arguments are
arrays, the algorithm in `https://developer.android.com/reference/java/util/Arrays#deepEquals(java.lang.Object[],%20java.lang.Object[])` is used to determine equality.
Otherwise, equality is determined by using the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method of the first argument.

<br />

| Parameters ||
|---|---|
| `a` | `Object`: an object <br /> |
| `b` | `Object`: an object to be compared with `a` for deep equality <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the arguments are deeply equal to each other and `false` otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/Arrays#deepEquals(java.lang.Object[],%20java.lang.Object[])`
- `https://developer.android.com/reference/java/util/Objects#equals(java.lang.Object,%20java.lang.Object)`

### equals

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

```
public static boolean equals (Object a, 
                Object b)
```


Consequently, if both arguments are `null`, `true`
is returned. Otherwise, if the first argument is not `null`, equality is determined by calling the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method of the first argument with the
second argument of this method. Otherwise, `false` is
returned.

<br />

| Parameters ||
|---|---|
| `a` | `Object`: an object <br /> |
| `b` | `Object`: an object to be compared with `a` for equality <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the arguments are equal to each other and `false` otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)`

### hash

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

```
public static int hash (Object... values)
```

The hash
code is generated as if all the input values were placed into an
array, and that array were hashed by calling `https://developer.android.com/reference/java/util/Arrays#hashCode(java.lang.Object[])`.

This method is useful for implementing `https://developer.android.com/reference/java/lang/Object#hashCode()` on objects containing multiple fields. For
example, if an object that has three fields, `x`, `y`, and `z`, one could write:

> ```
> @Override public int hashCode() {
>     return Objects.hash(x, y, z);
> }
> ```
**Warning: When a single object reference is supplied, the returned
value does not equal the hash code of that object reference.** This value can be computed by calling `https://developer.android.com/reference/java/util/Objects#hashCode(java.lang.Object)`.

<br />

<br />

| Parameters ||
|---|---|
| `values` | `Object`: the values to be hashed <br /> |

| Returns ||
|---|---|
| `int` | a hash code for a sequence of input values <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/Arrays#hashCode(java.lang.Object[])`
- `https://developer.android.com/reference/java/util/List#hashCode()`

### hashCode

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

```
public static int hashCode (Object o)
```

<br />

<br />

| Parameters ||
|---|---|
| `o` | `Object`: an object <br /> |

| Returns ||
|---|---|
| `int` | the hash code of a non-`null` argument and 0 for a `null` argument <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#hashCode()`

### isNull

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

```
public static boolean isNull (Object obj)
```

<br />

<br />

##### API Note:

- This method exists to be used as a `https://developer.android.com/reference/java/util/function/Predicate`, `filter(Objects::isNull)`

| Parameters ||
|---|---|
| `obj` | `Object`: a reference to be checked against `null` <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the provided reference is `null`; `false` otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/function/Predicate`

### nonNull

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

```
public static boolean nonNull (Object obj)
```

<br />

<br />

##### API Note:

- This method exists to be used as a `https://developer.android.com/reference/java/util/function/Predicate`, `filter(Objects::nonNull)`

| Parameters ||
|---|---|
| `obj` | `Object`: a reference to be checked against `null` <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the provided reference is non-`null`; `false` otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/function/Predicate`

### requireNonNull

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

```
public static T requireNonNull (T obj, 
                String message)
```

Checks that the specified object reference is not `null` and
throws a customized `https://developer.android.com/reference/java/lang/NullPointerException` if it is. This method
is designed primarily for doing parameter validation in methods and
constructors with multiple parameters, as demonstrated below:
>
> ```
> public Foo(Bar bar, Baz baz) {
>     this.bar = Objects.requireNonNull(bar, "bar must not be null");
>     this.baz = Objects.requireNonNull(baz, "baz must not be null");
> }
> ```

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `T`: the object reference to check for nullity <br /> |
| `message` | `String`: detail message to be used in the event that a `NullPointerException` is thrown <br /> |

| Returns ||
|---|---|
| `T` | `obj` if not `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `obj` is `null` |

### requireNonNull

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

```
public static T requireNonNull (T obj, 
                Supplier<String> messageSupplier)
```

Checks that the specified object reference is not `null` and
throws a customized `https://developer.android.com/reference/java/lang/NullPointerException` if it is.

Unlike the method `https://developer.android.com/reference/java/util/Objects#requireNonNull(T,%20java.lang.String)`,
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.

<br />

| Parameters ||
|---|---|
| `obj` | `T`: the object reference to check for nullity <br /> |
| `messageSupplier` | `Supplier`: supplier of the detail message to be used in the event that a `NullPointerException` is thrown <br /> |

| Returns ||
|---|---|
| `T` | `obj` if not `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `obj` is `null` |

### requireNonNull

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

```
public static T requireNonNull (T obj)
```

Checks that the specified object reference is not `null`. This
method is designed primarily for doing parameter validation in methods
and constructors, as demonstrated below:
>
> ```
> public Foo(Bar bar) {
>     this.bar = Objects.requireNonNull(bar);
> }
> ```

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `T`: the object reference to check for nullity <br /> |

| Returns ||
|---|---|
| `T` | `obj` if not `null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `obj` is `null` |

### requireNonNullElse

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

```
public static T requireNonNullElse (T obj, 
                T defaultObj)
```

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `T`: an object <br /> |
| `defaultObj` | `T`: a non-`null` object to return if the first argument is `null` <br /> |

| Returns ||
|---|---|
| `T` | the first argument if it is non-`null` and otherwise the second argument if it is non-`null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if both `obj` is null and `defaultObj` is `null` |

### requireNonNullElseGet

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

```
public static T requireNonNullElseGet (T obj, 
                Supplier<? extends T> supplier)
```

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `T`: an object <br /> |
| `supplier` | `Supplier`: of a non-`null` object to return if the first argument is `null` <br /> |

| Returns ||
|---|---|
| `T` | the first argument if it is non-`null` and otherwise the value from `supplier.get()` if it is non-`null` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if both `obj` is null and either the `supplier` is `null` or the `supplier.get()` value is `null` |

### toIdentityString

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

```
public static String toIdentityString (Object o)
```

<br />

<br />

##### Implementation Note:

- This method constructs a string for an object without calling any overridable methods of the object.

##### Implementation Requirements:

- The method returns a string equivalent to:  
  `o.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(o))`

| Parameters ||
|---|---|
| `o` | `Object`: an object <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string equivalent to the string returned by `Object.toString` if that method and `hashCode` are not overridden <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the argument is null |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#toString()`
- `https://developer.android.com/reference/java/lang/System#identityHashCode(java.lang.Object)`

### toString

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

```
public static String toString (Object o)
```

<br />

<br />

| Parameters ||
|---|---|
| `o` | `Object`: an object <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the result of calling `toString` for a non-`null` argument and `"null"` for a `null` argument <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#toString()`
- `https://developer.android.com/reference/java/lang/String#valueOf(java.lang.Object)`

### toString

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

```
public static String toString (Object o, 
                String nullDefault)
```

<br />

<br />

| Parameters ||
|---|---|
| `o` | `Object`: an object <br /> |
| `nullDefault` | `String`: string to return if the first argument is `null` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the result of calling `toString` on the first argument if the first argument is not `null` and the second argument otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/Objects#toString(java.lang.Object)`