Perhaps it makes no difference, but I want to know anyways. I want to know what it means to return an anonymous class such as in the following:
public class Module extends BaseModule {
private BaseInitializable initializeModule() {
return new BaseInitializable() {
public void initialize(InitializationContext context) {
helperA.initialize();
helperB.initialize();
s_logger.log(LogLevel.INFO,"something");
}
public void shutdown(InitializationContext context) {
}
};
}
}
Based on post 1, it seems the code is returning an anonymous inner class. But doesn't that go against the principle of an inner class in that they are only relevant to the parent class in which they reside (according to post 2)? The accepted answer in post 1 says the inner class is also sub class of the parent class. If that's true, then it makes sense to return this inner/sub class. But according to Post 2, inner classes are not subclasses. So what am I to make of this? Does this method return an instance of an inner class or a subclass?