Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

log()

Example

Return the natural logarithm of different numbers:

System.out.println(Math.log(6));
System.out.println(Math.log(Math.E));
System.out.println(Math.log(2));
System.out.println(Math.log(1));
System.out.println(Math.log(0));
System.out.println(Math.log(-1));
 

Definition and Usage

The log() method in Java computes the natural logarithm of a given number, where the base of the logarithm is the mathematical constant e (approximately 2.718282), which is accessible in Java through the Math.E constant.

Syntax

public static double log(double number)

Parameter Values

Parameter

Description

number

The parameter of the log() method specifies the value for which the logarithm is calculated. If this value is negative, the method returns NaN (Not a Number). If the value is 0, it returns -Infinity.

Technical Details

Return

The log() method returns a double value representing the natural logarithm of a given number.

Java Version

Any