Home »
Java programming language
Java PropertyPermission implies() Method with Example
PropertyPermission Class implies() method: Here, we are going to learn about the implies() method of PropertyPermission Class with its syntax and example.
Submitted by Preeti Jain, on March 21, 2020
PropertyPermission Class implies() method
- implies() method is available in java.util package.
- implies() method is used to check whether this PropertyPermission implies the given permission (perm) or not.
- implies() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
- implies() method does not throw an exception at the time of check implicate the given permission.
Syntax:
public boolean implies(Permission perm);
Parameter(s):
- Permission perm – represents the permission object to be tested.
Return value:
The return type of the method is boolean, it returns true when this object implies the given permission otherwise it returns false.
Example:
// Java program to demonstrate the example
// of boolean implies(Permission perm) method of
// PropertyPermission
import java.util.*;
public class ImpliesOfPropertyPermission {
public static void main(String arg[]) {
// Instantiates two PropertyPermission object
PropertyPermission prop_perm1 = new PropertyPermission("os.version", "write");
PropertyPermission prop_perm2 = new PropertyPermission("os.name", "read");
// By using implies() method isto
// check whether this PropertyPermission
// holds the given permission or not
boolean status1 = prop_perm1.implies(prop_perm1);
boolean status2 = prop_perm2.implies(prop_perm1);
// Display prop_perm1 status
System.out.print("prop_perm1.implies(prop_perm1): ");
System.out.println(status1);
// Display prop_perm2 status
System.out.print("prop_perm2.implies(prop_perm1): ");
System.out.println(status2);
}
}
Output
prop_perm1.implies(prop_perm1): true
prop_perm2.implies(prop_perm1): false