I can think of several cases where instances of Object
are useful:
- Locking and synchronization, like you and other commenters mention. It is probably a code smell, but I have seen Object instances used this way all the time.
- As Null Objects, because
equals
will always return false, except on the instance itself.
- In test code, especially when testing collection classes. Sometimes it's easiest to fill a collection or array with dummy objects rather than
null
s.
- As the base instance for anonymous classes. For example:
Object o = new Object() {...code here...}