package-private
is not a real modifier. You can't type package-private
and get the system to recognize it as an access modifier. It's really the default, made by not including any other modifiers.
It means that the given members can only be accessed in the same package.
For example, com.hexafraction.Cow
can access a member with default modifiers(none actually) in com.hexafraction.Dog
, but com.foo.Crow
can't access that member as it's not in the same pacakge.
In this example, the following makes up Cow
:
pacakge com.hexafraction;
class Cow{
void moo(){ //no public, protected, or private modifier
System.out.println("moo!");
}
}
Edit for the future: In Java 8, package
will supposedly be the modifier needed for this. Literally typing default
will still not apply here.