Number longValue() in Java

longValue(): This method is available in java.lang.Number class of Java.

Syntax:

long java.lang.Number.longValue()

This method returns the value of the specified number as a long.

Parameters: NA

Returns: the numeric value represented by this object after conversion to type long.

Exceptions: NA

Approach

Java

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

        Number number = 1234;
        System.out.println(number.longValue());
    }
}

Output:

1234

No comments:

Post a Comment