Java Tutorial/Access modifiers

< Java Tutorial

In Java, there are two types of access modifiers. They're public and private. A private can call a public, but a public can't call a private. Example:

public class PublicPrivate {
private static void main ( string[] args ) {
System.out.println("This method is private");
}
}
This article is issued from Wikiversity - version of the Tuesday, August 18, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.