sivarama sarma

Greenhorn
+ Follow
since Sep 20, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sivarama sarma

Nested Classes
Inner Classes
An inner class is a type of nested class that is not explicitly or implicitly declared static.
Inner class types
Local inner class.
A local class is a nested class that is not a member of any class and that has a name.
Every local class declaration statement is contained by a block.
The scope of a local class declared in a block is within the rest of the block.
Local class defined in a method has access to final method variables and also to the outer class's member variables.
example
Anonymous inner class.
Anonymous inner class does not have name.
It can extend a class or implement an interface but cannot do both at the same time. (For example, an anonymous inner class cannot say extends and implements at the same time.)
The definition, construction and first use of such class is at same place.
Programmer cannot define specific constructor for anonymous class but he/she can pass arguments (to call implicit constructor of its super class.)
An anonymous class is never abstract. An anonymous class is always an inner class; it is never static. An anonymous class is always implicitly final.
Anonymous class defined in a method has access to final method variables and also to the outer class's member variables.
Non-static member class.
A member class is a inner class whose declaration is directly enclosed in another class or interface declaration.
Member inner class can be public, private, protected or default/friendly.
Non-static member inner class has access to member variables of the outer class.
Non-static member inner class can be instantiated on the instance of the outer class.
example

Static nested classes.
Nested class can also be static. It has access to only static member variables of the outer class.
Static nested class may be instantiated/accessed without the instance of the outer class. It is accessed just like any other static member variable of a class.
For example, instance method accessTest() of public static nested class "Inner" can be invoked as...

new com.witscale.scjp.examples.Outer.Inner().accessTest();
hi please refer to this site for examples:http://www.witscale.com/scjp_studynotes/code_examples/chapter7