Access Java Java Classes

I have an outer class. I also have a private inner class that extends JPanel. This is the code of the code.

public class Outer{
    private class Inner extends JPanel{
        public void doSomeWork(){}
    }

    public Outer(){
        Inner inner = new Inner();
        inner.doSomeWork();
    }

    public static void main(String args[]){
        Outer outer = new Outer();
    }
}

I cannot access the doSomeWork () method of the inner class from the outer class. Please help.

+5
source share
1 answer

This is how you make an internal object and access its variables ...

Outer outer = new Outer(); 
Outer.Inner inner = outer.new Inner(); 
inner.doSomeWork();

Sample code from Oracle here ...

+12
source

All Articles