As we all know,Object
is the root class in Java. I found a class named Objects
that looks quite similar toObject
.
TheisObjects
class has confused me for a while. Can anybody tell me when and where we should use the Objects
class?
Objects
simply contains a set of utility methods that are useful in combination with Object
instances. Note that it can't be instantiated (it's final
and it has no public
constructor) and only contains static
methods.
The naming schema of putting utility methods in pluralized-name classes is pretty common in the JDK:
Collections
Arrays
(although strictly speaking there is no corresponding Array
class)Other libraries also use this scheme, for example Guava:
Maps
Strings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With