Anonymous Inner Class

  • Eclipse: Oxygen
  • Java: 1.8

The class having no name and which is used to overwrite an interface or an abstract method is called an anonymous inner class.

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.

Output

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
at org.studyeasy.Shop.main(Shop.java:9)

Output

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
at org.studyeasy.Shop.main(Shop.java:9)

Output

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
at org.studyeasy.Shop.main(Shop.java:9)

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