Yes, I can’t do it. For all those who comment on why this should not:
Imagine I have a class A that uses interface I. Class B extends class A, so it also inherits all the interface methods in A.
Now imagine that I want a private method in class A, but I want it to be defined by contract for other classes (perhaps class C, which does not necessarily extend class B or A).
Perhaps for the “initialization” method, which I want for all classes using the I interface. But, obviously, I do not want the initialization method to be publicly available ... because it should be used only once or, as the class considers, it is not necessary just because you want to use it willy-nilly.
The only solution is a workaround or just forcing the init method to be used in the classes themselves without an interface.
I understand the reason is not too, of course, but still, it can come in handy sometimes. Obviously, Oracle agrees that they allow private interface methods in JDK 9.
What I did, for me, in any case, contained a simple logical variable, so the interface method (which should be private) can be marked as true (initialized = true) after installation once. Then, when called again, the method simply does nothing. Thus, the interface method can be implemented as public, but since the constructor (of my class) first calls this method, it sets the variable to true and therefore it cannot be called again.
Otherwise, you have to try another workaround if you want the inner workings of this class to use it ... perhaps the method itself sets the on and off flag when it uses it. When the flag is false, the method does nothing (this would be when someone called it from outside the class). However, when the classes associated with its methods call it, they quickly set the flag to true, then call the method, and then set the flag to false ??
After all, dumb. Probably now it’s just better to just put the private class in the class itself and completely cut the interface.