Pregunta

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;
}
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top