问题
I don't understand package modifiers (not annotations) like this:
public package foo;
public class Bar {
}
Do they have any meaning?
回答1:
The only type of package modifier in the JLS is an annotation. From JLS 7.4.1:
PackageDeclaration:
{PackageModifier}
package
Identifier {. Identifier};
PackageModifier:
Annotation
So public package foo;
is invalid syntax.
This compiles under some versions of Eclipse, due to a bug which has been fixed in some conditions, and will be fixed in all conditions from Eclipse 4.4 onwards.
来源:https://stackoverflow.com/questions/25644292/whats-the-point-of-package-modifiers