-
public final class Objects
extends Object
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.
-
API Note:
- Static methods such as
checkIndex(int, int) , checkFromToIndex(int, int, int) , and checkFromIndexSize(int, int, int) are provided for the convenience of checking if values corresponding to indexes and sub-ranges are out-of-bounds. Variations of these static methods support customization of the runtime exception, and corresponding exception detail message, that is thrown when values are out-of-bounds. Such methods accept a functional interface argument, instances of BiFunction , that maps out-of-bound values to a runtime exception. Care should be taken when using such methods in combination with an argument that is a lambda expression, method reference or class that capture values. In such cases the cost of capture, related to functional interface allocation, may exceed the cost of checking bounds.
-
Since:
- 1.7
|
|