Java Integer intValue() Method
Example
Get the int value of an Integer object:
public class Main {
public static void main(String[] args) {
Integer myInt = 5;
int myNum = myInt.intValue();
System.out.println(myNum * 2);
}
}
Definition and Usage
The intValue() method returns the value of an Integer object as a primitive int (a simple value, not an object).
Java usually does this for you automatically, for example when you use an Integer in a calculation. This is called unboxing.
Syntax
public int intValue()
Parameter Values
None.
Technical Details
| Returns: | The value of the Integer, as an int. |
|---|
Related Pages
❮ Integer Methods