# ObjectsCompat

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#)  

# ObjectsCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
ObjectsCompat
`  
`

extends Object


``


`

|---|---------------------------------------|
| java.lang.Object                         ||
| ↳ | android.support.v4.util.ObjectsCompat |

<br />

*** ** * ** ***

This class consists of static utility methods for operating on objects.

## Summary

|                                                                                                                     ### Public methods                                                                                                                     ||
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static boolean` | ` `[equals](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#equals(java.lang.Object, java.lang.Object))`(Object a, Object b) ` Returns`true`if the arguments are equal to each other and`false`otherwise. |
| ` static int`     | ` `[hash](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#hash(java.lang.Object...))`(Object... values) ` Generates a hash code for a sequence of input values.                                           |
| ` static int`     | ` `[hashCode](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#hashCode(java.lang.Object))`(Object o) ` Returns the hash code of a non-`null`argument and 0 for a`null`argument.                           |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### equals

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Returns`true`if the arguments are equal to each other and`false`otherwise.

Consequently, if both arguments are`null`,`true`is returned and if exactly one argument is`null`,`false`is returned. Otherwise, equality is determined by using the[equals](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 equality <br /> |

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

**See also:**

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

### hash

added in[version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

This method is useful for implementing[hashCode()](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 ObjectsCompat.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[hashCode(Object)](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat#hashCode(java.lang.Object)).

<br />

<br />

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

|                          Returns                           ||
|-------|-----------------------------------------------------|
| `int` | a hash value of the sequence of input values <br /> |

**See also:**

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

### hashCode

added in[version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int hashCode (Object o)
```

Returns the hash code of a non-`null`argument and 0 for a`null`argument.

<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:**

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

  ## Interfaces

  - [Pools.Pool](https://developer.android.com/reference/android/support/v4/util/Pools.Pool)
-

  ## Classes

  - [ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)
  - [ArraySet](https://developer.android.com/reference/android/support/v4/util/ArraySet)
  - [AtomicFile](https://developer.android.com/reference/android/support/v4/util/AtomicFile)
  - [CircularArray](https://developer.android.com/reference/android/support/v4/util/CircularArray)
  - [CircularIntArray](https://developer.android.com/reference/android/support/v4/util/CircularIntArray)
  - [LongSparseArray](https://developer.android.com/reference/android/support/v4/util/LongSparseArray)
  - [LruCache](https://developer.android.com/reference/android/support/v4/util/LruCache)
  - [ObjectsCompat](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat)
  - [Pair](https://developer.android.com/reference/android/support/v4/util/Pair)
  - [PatternsCompat](https://developer.android.com/reference/android/support/v4/util/PatternsCompat)
  - [Pools](https://developer.android.com/reference/android/support/v4/util/Pools)
  - [Pools.SimplePool](https://developer.android.com/reference/android/support/v4/util/Pools.SimplePool)
  - [Pools.SynchronizedPool](https://developer.android.com/reference/android/support/v4/util/Pools.SynchronizedPool)
  - [SimpleArrayMap](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap)
  - [SparseArrayCompat](https://developer.android.com/reference/android/support/v4/util/SparseArrayCompat)