Lets say I have an outer class called 'Foo' and inside 'Foo' class I have a nested inner class called 'Bar'. Now inside 'Bar' class I have another inner called 'Choo'.
What I want to do is create an instance of 'Choo' class from a method inside outer class 'Foo', for example take the below code:
public class Foo {
// Other class fields
private class Bar {
// Other class fields
private class Choo {
// Other class fields
}
}
public void createChooObject() {
// Tried this but doesn't work
Bar.Choo theChooObject = new Bar.Choo();
// Also tried this but doesn't work
Bar.Choo theChooObject1 = Bar.new Choo();
}
}
Is this somehow possible or do I have to declare a method inside inner class 'Bar' a method which creates and returns the 'Choo' object?