09.07. Anonymous Object

Anonymous Object

  • Eclipse: Oxygen
  • Java: 1.8

The anonymous object simply means creating a new Object without assigning it to a reference. Hence this could be used only once in the execution of a program as it is not referenced to any object.

It is useful for writing implementation classes for listener interfaces in graphical programming.

Let us take a simple program, to understand an anonymous object.

Here, an object for Door class is not created. We can create a new Object without assigning it to a reference.

Contributed by: Poonam Tomar

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments