Given below the sample code :
class SuperClass {
SuperClass() {
}
static class SubClass {
SubClass() {
}
}
}
Which is the correct way to declare the object of "Subclass" , which can be use outside the "Superclass" ?
1. SubClass Sub = new SuperClass().new SubClass();
2. SubClass Sub = new SuperClass.SubClass();
3. SuperClass.SubClass Sub = new SuperClass.SubClass();
(3)
Because the inner class "Subclass" is declared 'static' that's why it is declared like this.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.