java.lang.Integer intValue()

Description :

This java tutorial shows how to use the intValue() method of Integer class under java.lang package. This method returns the int equivalent of this Integer object. The method intValue were inherited from Number class.

Method Syntax :

public int intValue()

Parameter Input :

DataType Parameter Description

Method Returns :

The intValue() method simply returns the numeric value represented by this object after conversion to type int.

Compatibility Version :

Requires Java 1.0 and up

Exception :


Java Code Example :

This java example source code demonstrates the use of intValue() method of Integer class. Basically we ask for user input on the console and then we use the scanner object to get the int input. After that we assign the value to an Integer wrapper class and then get the int equivalent using the intValue() method of Integer class.


import java.util.Scanner;

import static java.lang.System.*;

 * This example source code demonstrates the use of 
 * intValue() method of Integer class.

public class IntegerShortValue {

	public static void main(String[] args) {
		// Ask user input
		System.out.print("Enter Desired Value:");
		// declare the scanner object
		Scanner scan = new Scanner(;
		// use scanner to get the value from user console
		int intValue = scan.nextInt();
		// close the scanner object
		Integer myValue = new Integer(intValue);
		out.println("int Value is " + myValue.intValue());



Sample Output :

Running the intValue() method example source code of Integer class will give you the following output

Enter Desired Value:143
int Value is 143

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :