Home » Java programming language

Java PropertyPermission equals() Method with Example

PropertyPermission Class equals() method: Here, we are going to learn about the equals() method of PropertyPermission Class with its syntax and example.
Submitted by Preeti Jain, on March 21, 2020

PropertyPermission Class equals() method

  • equals() method is available in java.util package.
  • equals() method is used to check whether this object and the given object (ob) are equal or not.
  • equals() 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.
  • equals() method does not throw an exception at the time of checking the equality of two objects.

Syntax:

    public boolean equals(Object ob);

Parameter(s):

  • Object ob – represents the object to be tested with this object in this PropertyPermission.

Return value:

The return type of the method is boolean, it returns true when both the object are same, equals otherwise it returns false.

Example:

// Java program to demonstrate the example 
// of boolean equals(Object ob) method of 
// PropertyPermission

import java.util.*;

public class EqualsOfPropertyPermission {
 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 equals() method is to
  // whether two PropertyPermission
  // objects are same or not in terms
  // of name and actions
  boolean status = prop_perm1.equals(prop_perm2);

  System.out.print("prop_perm1.equals(prop_perm2): ");
  System.out.println(status);
 }
}

Output

prop_perm1.equals(prop_perm2): false


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.