is it possible to get restrict inner class constru...
# getting-started
a
is it possible to get restrict inner class constructor so that only the outer class can instantiate it? Here is the java code that can do it:
Copy code
public class Foo {
    public class FooInner {
        public final String key;
        private FooInner(String key) {
            this.key = key;
        }
    }
    public FooInner wrap(String key) {
        return new FooInner( key );
    }
}
A hack that may work, but would rather keep constructor public than use: https://stackoverflow.com/a/18634125/5130921
s
what if FooInner is an interface and wrap returns an anonymous class?!