Java Integer longValue() Method

The longValue() method is an instance method of Long class under java.lang package. This method returns the value of the specified long object as long equivalent. The longValue() method were inherited from the Number Class.

Syntax:

Following is the declaration of longValue() method:

Parameter:

DataTypeParameterDescription
NANAThis method does not accepts any parameter.

Returns:

The longValue() method returns the numeric value represented by this object after conversion to type long.

Exceptions:

NA

Compatibility Version:

Java 1.2 and above

Example 1

Output:

Value is = 121

Example 2

Output:

Enter The Desired Integer Value: 58648
Long Value is: 58648

Example 3

Output:

Value of l1 as long is: 298689
The Value of l2 as long is: -98723886