Java Data Type Tutorial - Java Math.log(double a)








Syntax

Math.log(double a) has the following syntax.

public static double log(double a)

Example

In the following code shows how to use Math.log(double a) method.

/* w  w  w.j a  va 2 s .  co m*/
public class Main {

   public static void main(String[] args) {
      double x = 123456.7;
      double y = -123.45;

      // get the natural logarithm for x
      System.out.println("Math.log(" + x + ")=" + Math.log(x));

      // get the natural logarithm for y
      System.out.println("Math.log(" + y + ")=" + Math.log(y));


   }
}

The code above generates the following result.