本文介绍了什么是“私人包裹”意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 请参阅示例:private package com.xm.aws;import static com.xml.aws.PcgTest.test;public class PackageTest { public static void main(String[] args) { test(args); }} private 告诉我有关该软件包的信息?What does the private tell me about the package?推荐答案我们不要将此与 package-private混淆或其他可以添加到类,方法和字段的访问修饰符。Let's not confuse this with package-private or other access modifiers that can be added to classes, methods and fields. Java语言规范明确指出: 始终可以访问包。 考虑到这一点,我想到的唯一答案是,(某些)编译器不会将此视为编译时错误,而是完全没有意义。无法限制方式(方式)的类或包的可访问性(并且每个包都可以访问)。Looking at that, the only answer, that comes to my mind is, that (some) compilers don't treat this as a compiletime error but that it is completely meaningless. It is not possible to restrict accessibility to a class or package that way (and every package is always accessible). java语言规范: 编译单元中的包声明指定编译单元所属的包的名称(第6.2节)。A package declaration in a compilation unit specifies the name (§6.2) of the package to which the compilation unit belongs. PackageDeclaration:PackageDeclaration:注释 opt package PackageName; Annotationsopt package PackageName ;因此关键字可以在注释之前。但是访问修饰符不是包声明的一部分。即使我们扩展注释 我们在这里找不到访问修饰符。So the keyword may be preceeded by annotations. But the access modifiers is not part of the package declaration. And even if we expand on "Annotations" we won't find access modifiers here.另一个引用,根据 JLS 18.语法唯一允许在 package 之前的东西是一个注释。Another reference, according to JLS 18. Syntax the only thing allowed to precede package is an Annotation. 这篇关于什么是“私人包裹”意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 16:45