开发者

Java multiple class definitions in the same file

开发者 https://www.devze.com 2023-02-13 17:41 出处:网络
just a simple question, if you have the following code in a file called Example.java: package MyPackage;

just a simple question, if you have the following code in a file called Example.java:

package MyPackage;

public class Example{
   void foo(){}
   ...
   ...
}

class A{}
class B{}

what is the modifier of the cl开发者_运维百科ass A and B?


They have the default modifier, which means package-private. See here


They are both default visibility (package private).

  • Controlling Access to Members of a Class (Java Tutorial)
0

精彩评论

暂无评论...
验证码 换一张
取 消