Skip to Content

Find natural logarithm value of a number using Math.log

  1. /*
  2.   Find natural logarithm value of a number using Math.log
  3.   This java example shows how to find natural logarithm value of a
  4.   number using log method of Java Math class.
  5. */
  6.  
  7. public class FindNaturalLogarithmOfNumberExample {
  8.  
  9.   public static void main(String[] args) {
  10.    
  11.     /*
  12.      * To find natural logarithm value of a number, use
  13.      * static double log(double d) method of Java Math class.
  14.      */
  15.    
  16.      System.out.println("Natural logarithm value of 2 is : " + Math.log(2));
  17.   }
  18. }
  19.  
  20. /*
  21. Output would be
  22. Natural logarithm value of 2 is : 0.6931471805599453
  23. */