System.nanoTime() in Java

System.nanoTime() : This method is available in java.lang.System class of Java.

Syntax:

long java.lang.System.nanoTime()

This method returns the current value of the running Java Virtual Machine'shigh-resolution time source, in nanoseconds. This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time.

Parameters: NA

Returns: the current value of the running Java Virtual Machine'shigh-resolution time source, in nanoseconds.

Exceptions: NA

Approach

Java

public class SystemnanoTime {
    public static void main(String[] args) {

        System.out.println(System.nanoTime());
    }
}

Output:

72165237117700


No comments:

Post a Comment