Java.lang Package Classes

Java Short - intValue() Method



The java.lang.Short.intValue() method returns the value of this Short as an int after a widening primitive conversion.

Syntax

public int intValue()

Parameters

No parameter is required.

Return Value

Returns the numeric value represented by this object after conversion to type int.

Exception

NA.

Example:

In the example below, the java.lang.Short.intValue() method returns a Short object after conversion to type int.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating Short objects
    Short val1 = 25;
    Short val2 = -25;

    //printing intValue of the Short objects
    System.out.println("intValue of the val1 is: " + val1.intValue()); 
    System.out.println("intValue of the val2 is: " + val2.intValue());   
  }
}

The output of the above code will be:

intValue of the val1 is: 25
intValue of the val2 is: -25

❮ Java.lang - Short