Level toString() method in Java with Examples
Last Updated :
14 Oct, 2019
The toString() method of java.util.logging.Level is used to get the string value which represents this Level.This method returns a string representation of this Level.
Syntax:
public String toString()
Parameters: This method accepts nothing.
Return: This method returns a string representation of this Level..
Below programs illustrate toString() method:
Program 1:
import java.util.logging.Level;
import java.util.logging.Logger;
public class GFG {
public static void main(String[] args)
{
Logger logger
= Logger.getLogger(
String. class .getName())
.getParent();
Level level
= logger.getLevel();
String val = level.toString();
System.out.println( "toString = "
+ val);
}
}
|
Program 2:
import java.util.logging.Level;
public class GFG {
public static void main(String[] args)
{
Level level
= Level.parse( "SEVERE" );
String value = level.toString();
System.out.println( "toString = "
+ value);
}
}
|
Output:
toString = SEVERE
References: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Level.html#toString()
Share your thoughts in the comments
Please Login to comment...