java.lang.Short intValue()
Description
The intValue() method of Short class returns the value of this Short as an int after a widening primitive conversion.
Important Notes:
- This method is specified by intValue in class Number.
Method Syntax
public int intValue()
Method Argument
| Data Type | Parameter | Description |
|---|---|---|
| N/A | N/A | N/A |
Method Returns
The intValue() method of Short class returns the numeric value represented by this object after conversion to type int.
Compatibility
Requires Java 1.1 and up
Java Short intValue() Example
Below is a simple java example on the usage of intValue() method of Short class.
package com.javatutorialhq.java.examples;
/*
* This example source code demonstrates the use of
* intValue() method of Short class
*/
public class ShortIntValueExample {
public static void main(String[] args) {
// Declare a new Short variable
Short value = 123;
// get the intValue() method result
int result = value.intValue();
// print the result
System.out.println("Result:" + result);
/*
* Be careful on using this method
* Desired result might differ
* because of the widening concept
* of java language
*/
}
}
