What's the point of package modifiers?

本秂侑毒 提交于 2020-01-24 23:40:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!