mercredi 8 avril 2020

Need to access a field present inside a private inner class

class OuterClass {
    // The below object will be initiated somewhere within
    private OuterClass.InnerClass innerClassObj;
    private class InnerClass {
        {
            int innerClassVariable;
        }
    }
}

class SomeOtherClass {
     public static void main(String args[])
     {
         OuterClass outerClassObj = new OuterClass();
     }
}

I need to access the field 'innerClassvariable' present in 'InnerClass' Using 'innerClassObj' present in 'OuterClass' from 'SomeOtherClass'





Aucun commentaire:

Enregistrer un commentaire