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. ja  v  a2 s  .com*/
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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable