0

What's the difference between them and how can I use Objects?

Objects                 |        Object
java.util               |        java.lang
Class Objects           |        Class Object

java.util.Objects       |        java.lang.Object
5
  • 7
    Objects is a utility class for Object. Commented May 11, 2015 at 7:27
  • No need to use 'Objects', if it is necessary, the class 'Object' will use them Commented May 11, 2015 at 7:32
  • 1
    ... and you can look at its JavaDoc to see what these utility methods are: docs.oracle.com/javase/7/docs/api/java/util/Objects.html Commented May 11, 2015 at 7:33
  • @Phil Objects is quite useful... Commented May 11, 2015 at 7:52
  • @assylias I see, I did some reading up. Had previously thought you could access these methods through 'Object' aswell Commented May 11, 2015 at 7:55

2 Answers 2

5

The javadoc can help:

java.lang.Object

Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.

java.util.Objects

This class consists of static utility methods for operating on objects. These utilities include null-safe or null-tolerant methods for computing the hash code of an object, returning a string for an object, and comparing two objects.

Sign up to request clarification or add additional context in comments.

3 Comments

I wonder what the difference between null-safe and null-tolerant is.
@PieterDeBie It means if reference is not pointing to anyone or it is null, it will run and it will not show null pointer exception
So, no difference between them?
3

Object is a implicit base class for all classes in java. Objects is a utility class introduced in java 7 that contains several very convenient static utility methods.

1 Comment

Objects indeed utility. However there is a lot to learn more.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.