Java Math log() method with example Last Updated : 04 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.lang.Math.log() method returns the natural logarithm (base e) of a double value as a parameter. There are various cases : If the argument is NaN or less than zero, then the result is NaN.If the argument is positive infinity, then the result is positive infinity.If the argument is positive zero or negative zero, then the result is negative infinity. Syntax : public static double log(double a) Parameter : a : User input Return Type: This method returns the value ln a. Example 1: To show the working of java.lang.Math.log() method. java // Java program to demonstrate working // of java.lang.Math.log() method import java.lang.Math; class GFG { // driver code public static void main(String args[]) { double a = -2.55; double b = 1.0 / 0; double c = 0, d = 145.256; // negative integer as argument, output NAN System.out.println(Math.log(a)); // positive infinity as argument, output Infinity System.out.println(Math.log(b)); // positive zero as argument, output -Infinity System.out.println(Math.log(c)); // positive double as argument System.out.println(Math.log(d)); } } Output:NaN Infinity -Infinity 4.978497702968366 Example 2: Java import java.io.*; class GFG { public static void main(String[] args) { double number = 10.0; double result = Math.log(number); System.out.println(result); } } Output2.302585092994046 Comment More infoAdvertise with us Next Article Java Math log() method with example N Niraj_Pandey Follow Improve Article Tags : Java java-math Practice Tags : Java Similar Reads Math pow() Method in Java with Example The Math.pow() method in Java is used to calculate a number raised to the power of some other number. It is part of the java.lang.Math class and is widely used in mathematical computations, scientific calculations, and algorithmic problems. This function accepts two parameters and returns the value 3 min read Logger log() Method in Java with Examples The log() method of Logger is used to Log a message. If the logger is currently enabled for the given message level which is passed as parameter then a corresponding LogRecord is created and forwarded to all the registered Output Handler objects. But in logger class, there are seven different log() 6 min read Logger fine() method in Java with Examples The fine() method of a Logger class used to Log a FINE message. This method is used to pass FINE types logs to all the registered output Handler objects. FINE, FINER and FINEST provide tracking information as when what is happening/ has happened in our application. FINE displays the most important m 3 min read LogManager reset() method in Java with Examples The reset() method of java.util.logging.LogManager is used to reset the logging configuration. This method throws SecurityException if the exception condition occurs, as given below Syntax: public void reset() throws SecurityException Parameters: This method does not accepts any parameter. Return Va 1 min read Logger finer() method in Java with Examples The finer() method of a Logger class used to Log an FINER message.This method is used to pass FINER types logs to all the registered output Handler objects. FINER message: FINER outputs a detailed tracing message and may include logging calls regarding method entering, exiting, throwing exceptions. 3 min read Like