Anonymous Object

  • Eclipse: Oxygen
  • Java: 1.8

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 variable.

It is an inner class with no name and for which a single object is created. An anonymous inner class can be useful when creating an instance of an object with certain “extras”, such as the overload methods of a class or interface, without having to actually subclass a class.

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

Contributed by: Poonam Tomar


VIEW COURSES

Buy me a coffee!

 

PayTM QR (INDIA)

  • Get video tutorials
  • Project files set
  • Get┬áCertified

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu