Java Short.doubleValue() example

Java Short.doubleValue() example

By Yashwant Chavan, Views 6, Date 24-Apr-2018

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

tags Java

Returns the value of this Short as a double.

Syntax

public double doubleValue()

Returns

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

Java Short doubleValue() example

  • Assign two short values.
  • Create an instance of short values e.g new Short(value);
  • firstValue.doubleValue();It will return the double value of firstValue.
  • secondValue.doubleValue();It will return the double value of secondValue.
  • Print the double 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);

        double result1 = firstValue.doubleValue();
        double result2 = secondValue.doubleValue();

        System.out.println("The double value of firstValue :- " + result1);
        System.out.println("The double value of secondValue :- " + result2);
    }
}

output

The double value of firstValue :- 50.0
The double value of secondValue :- -20.0

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]