class outside{
int a,b;
static void w(){
inner x=new inner();
x.y();
}
static class inner{
void y(){
System.out.println("Print");
}
}
}
class example43{
public static void main(String args[]){
outside r=new outside();
r.w();
}
}
in the above code if inner class is not made static then that results in an error when x is declared in w. why?
if the reason is that a static method may not call a non static method then another error should when x.y() is executed because y is not a static method. is the error not occurring because somehow making the inner class static has automatically made the method y static?
what is the meaning of making a class static?


Sign In
Create Account


Back to top









