Tuesday, November 19, 2024
Google search engine
HomeLanguagesJavaLevel equals() method in Java with Examples

Level equals() method in Java with Examples

The equals() method of java.util.logging.Level is used to check if this level object is equals to passed object or not.If both objects are equals then method will return true else false.

Syntax:

public boolean equals(Object ox)

Parameters: This method accepts an object ox which is the reference object with which to compare.

Return: This method returns true if and only if the two objects have the same level value.

Below programs illustrate equals() method:
Program 1:




// Java program to illustrate equals() method
  
import java.util.logging.Level;
import java.util.logging.Logger;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Create a Logger
        Logger logger
            = Logger.getLogger(
                        Object.class.getName())
                  .getParent();
  
        // Get level of logger
        Level level1
            = logger.getLevel();
  
        // Create a second Logger
        Logger logger2
            = Logger.getLogger(
                        String.class.getName())
                  .getParent();
  
        // Get level of second logger
        Level level2
            = logger2.getLevel();
  
        // apply equal method
        boolean value = level1.equals(level2);
  
        // print level names
        System.out.println("Both level are equal = "
                           + value);
    }
}


Output:

Both level are equal = true

Program 2:




// Java program to illustrate equals() method
  
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Create a Logger
        Logger logger
            = Logger.getLogger(
                        Object.class.getName())
                  .getParent();
  
        // Get level of logger
        Level level1
            = logger.getLevel();
  
        // Create a second Logger for ArrayList class
        Logger logger2
            = Logger.getLogger(
                ArrayList.class.getName());
  
        // Get level of second logger
        Level level2
            = logger2.getLevel();
  
        // apply equal method
        boolean value = level1.equals(level2);
  
        // print level names
        System.out.println("Both level are equal = "
                           + value);
    }
}


Output:

Both level are equal = false

References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Level.html#equals(java.lang.Object)

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments