Java Integer.longValue() – Examples

In this tutorial, we will learn about Java Integer.longValue() method, and learn how to use this method to get the value of this integer object as long value, with the help of examples.


Integer.longValue() returns the value of this Integer as a long after a widening primitive conversion.



The syntax of longValue() method is



The method returns value of type long.

Example – longValue()

In this example, we will take an Integer object and get an equivalent long value of this integer object.

Java Program

public class Example {
	public static void main(String[] args){
		Integer integer = 20;
		long result = integer.longValue();
		System.out.println("Result of longValue() = " + result);


Result of longValue() = 20


In this Java Tutorial, we have learnt the syntax of Java Integer.longValue() method, and also how to use this method with the help of Java example programs.