Java.lang.Short.intValue() Method

Advertisements


Description

The java.lang.Short.intValue() method returns the value of this Short as an int.

Declaration

Following is the declaration for java.lang.Short.intValue() method

public int intValue()

Parameters

  • NA

Return Value

This method returns the numeric value represented by this object after conversion to type int.

Exception

  • NA

Example

The following example shows the usage of java.lang.Short.intValue() method.

package com.tutorialspoint;

import java.lang.*;

public class ShortDemo {

   public static void main(String[] args) {

     // create short object and assign value to it
     short sval = 30;
     Short sobj = new Short(sval);
    
     // returns int value of Short
     int intValue = sobj.intValue(); 
    
     // printing int value
     System.out.println("int value of Short is = " + intValue);
  }
}  

Let us compile and run the above program, this will produce the following result:

int value of Short is = 30



Advertisements
Advertisements