I'll preface this with I believe I understand how the access level modifiers work in Java. My question has to do with the difference between protected and package-private (no modifier) when used in a final class.
From my understanding:
If you declare a class as final you aren't able to extend it, which means that there won't be any subclasses of it
If you don't add a modifier to a method (package-private) it is visible only within its own package
If you declare a method protected it can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package
My question is if your class is a final class, is there any difference between package-private and protected? The final modifier makes it so that there can't be any subclasses, so it doesn't seem like there can be a subclass in another package. Which means that in either case it will just be visible in its own package.
In a final class is there a difference between the two?
If there is no difference is one supposed to be used over the other or does it not matter?