java - Using a non static data member in to a non static nested class withourt using object -
class outer {     int x=10;     class inner     {         void show()         {             system.out.println(x);         }     }     public static void main(string args[])     {         outer obj=new outer();         inner obj1=new outer().new inner();         obj1.show();     } }   i tried making non static nested class , tried use non static data member of outer class in non static inner class. did not if x non static, how using without object. kindly give me answer?
you're not using without object. inner (non-static nested) classes have reference outer object, x used.
Comments
Post a Comment