Java Short.intValue() example

By Yashwant Chavan, Views 37, Last updated on 22-Feb-2019

In this java tutorial, You will learn how to use intValue() method of Short class. This method, Returns the value of this Short as an int. This method returns the numeric value represented by this object after conversion to type int.

tags Java

Returns the value of this Short as an int.

Syntax

public int intValue()

Returns

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

Java Short intValue() example

  • Assign two short values.
  • Create an instance of short values e.g new Short(value);
  • firstValue.intValue();It will return the int value for firstValue.
  • secondValue.intValue();It will return the int value for secondValue.
  • Print the int values.
package com.technicalkeeda;

public class App {

    public static void main(String[] args) {

        short value1 = 50;
        Short firstValue = new Short(value1);

        short value2 = -20;
        Short secondValue = new Short(value2);

        System.out.println("The int value :- " + firstValue.intValue());
        System.out.println("The int value :- " + secondValue.intValue());
    }
}

output

The int value :- 50
The int value :- -20

Suggested Posts

Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]