Access control modifier and non-access modifier are two types of modifiers in Java.
Access control modifier
There are four access modifiers available in Java, used to set access levels for classes, variable methods and constructor.
Non-Access modifier
There are five non-access modifiers available in Java, used to achieve many other functionality.
Example:
class Phone
{
final int PRICE_MIN = 999;
final int PRICE_MAX = 5600; //final variable
final void display() //final method
{
System.out.println("Min Price is" + PRICE_MIN);
System.out.println("Max Price is" + PRICE_MAX );
}
}
Example:
class Programming {
public static void main(String[] args) {
display();
}
static void display() {
System.out.println("I love to programming in Java.");
}
}
0 comments:
Post a Comment