What's the use case of a protected method in a final class in Java?
问题 Consider this code from the official OpenJDK source of java.awt.font.TextLayout : public final class TextLayout { /* ... */ protected void handleJustify(float justificationWidth) { // never called } } What's the use case here and why might it make sense to write code like that in general? 回答1: protected members can still be accessed by code from the same package. My guess is that the class used to be non-final in some earlier (perhaps not even public) version, was then made final, and the