Doubt in Inner class

hi ,

i have a doubt. How we can access a Inner class name by the outer class name using the Dot(.) operator .

For example if we want to refer to the Inner class in some other class

then we must say "OuterClass.InnerClass".

This type of syntex is ment for the static methods in a class.

Thus can we assume that Inner class is also a type of static member.

If not then please explain the syntex.

i am also not getting the way we create object of the Inner class object in some other class .(i mean to say the logic behind the syntex)

i.e

OuterClass Ob1=new OuterClass();

OuterClass.InnerClass InnOb=Ob1.new InnerClass();

Cna any one please help me out.

Regards

Arunabh

[776 byte] By [jublua] at [2007-10-2 13:46:35]
# 1

Hi,

Inner classes are used to create some functionality in terms of OO way. Like you want to have event handling which will work only for designated GUI classes, then we can make use of Innner class.

Within a outer classes we do not require any reference of outer object BUT, if you want to access Inner class object outside the class then only we need a reference of Outer object so that we instantitate Inner class object.

thanks,

Sandeep

chauhansandeepa at 2007-7-13 11:44:12 > top of Java-index,Java Essentials,Java Programming...
# 2

public class Outer {

public Outer() {

System.out.println("Outer created.");

}

public static class Inner {

public Inner() {

System.out.println("Inner created.");

}

}

}

prometheuzza at 2007-7-13 11:44:12 > top of Java-index,Java Essentials,Java Programming...