Question: Inner classes
Hi I am bharat . I am student learning java course . I have one question about inner classes . question is how to access the instance method of
Non-static classes which is defined in the outer class that is main class . I didn√Ę‚?¨‚?Ęt understand following code Suppose that Outer is Main class that is class Outer and Inside that class there is Inner class defined .
A) Outer ob = new Outer(); Ob.display(); // calling instance method of Outer class Outer.Inner ob1= ob.new Inner(); // creating object of non static class Then if the above code is correct then why don√Ę‚?¨‚?Ęt we write like that
B) Outer ob = new Outer();
ob.Inner ob1= ob.new Inner();
above code in B section . I am getting error that package ob doesn√Ę‚?¨‚?Ęt exist one more thing is that we onle static member we can access along with class name but here non static class in outer class called as like that while referring reference name . is that right way ? strong text
please √Ę‚?¨¬¶give some explanation on it