This is maybe a dumb question, but I'm pretty surprised to see that using the private inner class as a generic type in the outer class isn't allowed.
If I make the inner class protected, it compiles fine.
Additionally, I have to precise Outer.Inner instead of just Inner, otherwise the inner class isn't found. This also looks a little weird.
Why can't Inner be private ? And why it is allowed to be protected ?
public class Outer extends AbstractSet<Outer.Inner> {
private static class Inner {
// ...
}
// ...
}
The error is:
Outer.java:3: error: Inner has private access in Outer
public class Outer extends AbstractSet<Outer.Inner> {
^
1 error
I'm using Java SE 17, but I think it doesn't matther much.