Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public final class

Objects

extends Object
java.lang.Object
   ↳ java.util.Objects

Class Overview

Utility methods for objects.

Summary

Public Methods
static <T> int )">compare (T a, T b, Comparator <? super T> c)
Returns 0 if a == b , or c.compare(a, b) otherwise.
static boolean deepEquals ( Object a, Object b)
Returns true if both arguments are null, the result of equals(boolean[], boolean[]) if both arguments are primitive arrays, the result of deepEquals(Object[], Object[]) if both arguments are arrays of reference types, and the result of equals(Object) otherwise.
static boolean equals ( Object a, Object b)
Null-safe equivalent of a.equals(b) .
static int hash ( Object... values)
Convenience wrapper for hashCode() , adding varargs.
static int hashCode ( Object o)
Returns 0 for null or o.hashCode() .
static <T> T requireNonNull (T o, String message)
Returns o if non-null, or throws NullPointerException with the given detail message.
static <T> T requireNonNull (T o)
Returns o if non-null, or throws NullPointerException .
static String toString ( Object o, String nullString)
Returns nullString for null or o.toString() .
static String toString ( Object o)
Returns "null" for null or o.toString() .
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

)">

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

Returns 0 if a == b , or c.compare(a, b) otherwise. That is, this makes c null-safe.

public static boolean deepEquals ( Object a, Object b)

Returns true if both arguments are null, the result of equals(boolean[], boolean[]) if both arguments are primitive arrays, the result of deepEquals(Object[], Object[]) if both arguments are arrays of reference types, and the result of equals(Object) otherwise.

public static boolean equals ( Object a, Object b)

Null-safe equivalent of a.equals(b) .

public static int hash ( Object... values)

Convenience wrapper for hashCode() , adding varargs. This can be used to compute a hash code for an object's fields as follows: Objects.hash(a, b, c) .

public static int hashCode ( Object o)

Returns 0 for null or o.hashCode() .

public static T requireNonNull (T o, String message)

Returns o if non-null, or throws NullPointerException with the given detail message.

public static T requireNonNull (T o)

Returns o if non-null, or throws NullPointerException .

public static String toString ( Object o, String nullString)

Returns nullString for null or o.toString() .

public static String toString ( Object o)

Returns "null" for null or o.toString() .