Hello guys
I have a question regrading the inner class created inside a method.My book says that the Object of the inner class outlives the method. so i created an example.
class outer{
Object raj(){
final int a=1;
class inner {
void mmethod(){
System.out.println("Final "+a);
}
}
return new inner();
}
}
public class
test {
public static void main(
String z[]){
outer out = new outer();
Object ob=out.raj();
ob.mmethod();
}
}
Iam creating a class inside a method and trying to keep that class object outlive the method, so iam returning the object created inside the method and storing it in variable reference of type Object, when i tried to invoke the method with that object reference it is throwing an expection as follows
symbol : method mmethod ()
location: class java.lang.Object
ob.mmethod();
can any one help me, i want to invoke the method using the object reference.I even tried casting the object reference.
[ January 19, 2003: Message edited by: Raj Neets ]
[ January 19, 2003: Message edited by: Raj Neets ]