包修饰符的意义是什么? [英] What's the point of package modifiers?

查看:104
本文介绍了包修饰符的意义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白这样的包装修饰符(不是注释):

I don't understand package modifiers (not annotations) like this:

public package foo;

public class Bar {
}

它们有什么意义吗?

推荐答案

JLS中包修饰符的 only 类型是注释.来自 JLS 7.4.1 :

The only type of package modifier in the JLS is an annotation. From JLS 7.4.1:

PackageDeclaration:
{PackageModifier} package 标识符{.标识符} ;

PackageDeclaration:
{PackageModifier} package Identifier {. Identifier} ;

PackageModifier:
注释

PackageModifier:
Annotation

所以public package foo;是无效的语法.

由于 bug ,它可以在某些Eclipse版本下编译在某些情况下已经修复,并且将从Eclipse 4.4开始在所有情况下修复.

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.

这篇关于包修饰符的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆