Saturday, October 25, 2025
HomeLanguagesJavaLevel intValue() method in Java with Examples

Level intValue() method in Java with Examples

The intValue() method of java.util.logging.Level is used to get the integer value for this level object. Every level has an integer value associated with it. This integer value can be used for efficient ordering comparisons between Level objects. This method is helpful if we want to use the int value of a level object for comparison purposes in logging.

Syntax:

public int intValue()

Parameters: This method accepts nothing.

Return: This method returns the integer value for this level object.

Below programs illustrate intValue() method:
Program 1:




// Java program to illustrate
// intValue() 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(
                        String.class.getName())
                  .getParent();
  
        // Get level of logger
        Level level
            = logger.getLevel();
  
        // get intValue
        int val = level.intValue();
  
        // print result
        System.out.println("intValue = "
                           + val);
    }
}


Output:

intValue = 800

Program 2:




// Java program to illustrate
// intValue() method
  
import java.util.logging.Level;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Get level of logger
        Level level
            = Level.parse("SEVERE");
  
        // get int code
        int value = level.intValue();
  
        // print result
        System.out.println("intValue = "
                           + value);
    }
}


Output:

intValue = 1000

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS