Programming | Android | Tips N Tricks

Post Page Advertisement [Top]

THE ANONYMOUS CLASS are the class which do not have name.

We can define class in the class as we define method and constructor. We can define class locally as inside a method or constructor or any block that we want. ANONYMOUS class used in that part we we don't have to specify the name of locally define class.

How to create instance of ANONYMOUS class ?
ANONYMOUS class are defined and created at the same place. 

ANONYMOUS class can become part of an "Expression".
ANONYMOUS class can have only single Inheritance. 

what do you mean by Single Inheritance?
Single Inheritance means ANONYMOUS class can inherit from a class or it can implement only one "Interface". 

ANONYMOUS class are always non-abstract since their instance is going to be created.

When we use ANONYMOUS class?
When we need any instance of class which implementing a single interface or extending a class without giving name to the class we use ANONYMOUS class.

Syntax :
new <super-type-constructor-invocation> <class definition>

No comments:

Post a Comment

Comments

Bottom Ad [Post Page]

| Designed by Colorlib