I know what the difference between private, public and protected. but I don't know what the difference between private field and filed without any access modifiers.

class Example{
private int field1;
int field2;
}
有帮助吗?

解决方案

In Java if you leave the access specifier off then the member is "package" level. Package level members can be seen by the class that defines the member and other classes in the same package. The difference between that and private are private members may only be seen by the class which defines it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top