How do I create an instance of a static private inner class with a public constructor?
public class outerClass<E> {
private static class innerClass<E> {
E value;
public innerClass(E e) {
value = e;
}
}}
I've tried this and it gives an error that the out package does not exist
outerClass<Integer> out = new outerClass<Integer>();
out.innerClass<Integer> = new out.innerClass<Integer>(1);
I've tried this and it gives an error that the inner class is private and can't be accessed.
outerClass<Integer>.innerClass<Integer> = new
outerClass<Integer>.innerClass<Integer>(1)
But this doesn't make sense.
innerClassis declaredstatic, which means that innerClass has nothing to do withouterClass; it is merely located within it for namespacing purposes (and, perhaps, that outer and inner can accessprivatemembers), but that is where it ends. So,out, being an instance ofouterClass, has no business being there.That also doesn't make any sense - outerClass is being mentioned here just for the purposes of namespacing: To tell java what class you mean. Thus, the
<Integer>on that makes no sense.how do I do it then?