4 ms·
"I have never bothered to learn, nor will I, what the default modifiers for Java’s variables and methods are" That means that he doesn't understand "package" l
by kaffeinecoma 16y ago
"I have never bothered to learn, nor will I, what the default modifiers for Java’s variables and methods are"
That means that he doesn't understand "package" level access. There is no "package" keyword (well, there is, but it means something else). To get package-private access you have to leave it unspecified, so that means he can't use this feature. Or grok it when he comes across it.
The lack of a keyword for this is a shortcoming in Java, IMHO. But even if you don't use it often, you should have an inkling of how it works.
http://stackoverflow.com/questions/403583/what-is-the-use-of-package-level-protection-in-java http://stackoverflow.com/questions/403583/what-is-the-use-of...
- Tichy 16y agoIt rarely ever seems to be useful, though?
- loumf 16y agoI've used it for unit-testing -- gives the test class a little more access.
- thomas11 16y agoExactly. To elaborate a bit for those who never used it in that way: you want to separate your unit tests from your app code. But you still want to give your tests access to non-public methods in order to test them independently. The solution is to put app code and tests in different folders, but in the same packages, and make everything you want to test package-scoped.
- tripa 16y agoMight be a vicious circle: no one knows about it -> no cool uses of it are found -> no one uses it -> loop.
- chopin 16y agoMost of my classes are package private. It is just a matter of information hiding. Especially when using factory patterns I hand out only public interfaces whereas the implementations are kept package private.
- kaffeinecoma 16y agoIronically, it's quite commonly in use in Google's code base. GWT in particular.
- jsvaughan 16y agoyeah i thought that was surprising. operator precedence is one thing, but not knowing about default modifier, not so good.