Java multiple class definitions in the same file
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)
精彩评论