Monday, 1 October 2012

inner classes in java







There are 4 kind of classes that can be defined in a Java program, roughly can be termed as the inner classes.

--  Inner classes provides an elegant and powerful feature to the Java programming language. 
-- These inner classes are referred by different names in different situations. 
-- They are summarized here:
  1. Static member classes
  2. Member classes
  3. Local classes
  4. Anonymous classes

-- The term "nested classes" sometimes refers to these inner classes.

Static member classes

  -- This class (or interface) is defined as a static member variable of another class.
Member classes

--  This is sometimes defined as a non-static member of an enclosing class. This type of inner class is analogous to an instance method or field.

Local classes
-- This class is defined within a block of Java code so like a local variable, it is visible only within that block.

Anonymous classes
-- An anonymous class is a  local class having no name; 
-- Syntactically it combines the syntax required for defining a class and the syntax required to instantiate an object. 

No comments:

Post a Comment

There was an error in this gadget