I just moved on to the following code, which surprised me a little, but I converted it to a simple SSCEE:
custompackage.package1.MyEnum.java
public enum MyEnum implements MyInterface { CONSTANT_ONE() { @Override public void myMethod() {
Now from outside this package, I can do the following:
Consumer<MyEnum> myMethod = MyEnum::myMethod;
However, I generally cannot use MyInterface , which I understand, since it is a private-package for custompackage.package1 .
I donβt understand what exactly is happening, but it seems that MyEnum received the myMethod() method, but it does not implement (externally) MyInterface .
How it works?
java enums package-private interface
skiwi
source share