java.lang.Integer doubleValue()

Description :

This java tutorial shows how to use the doubleValue() method of Integer class under java.lang package. This method returns the double equivalent of this Integer object. The method doubleValue() were inherited from Number class.

Method Syntax :

public long doubleValue()

Parameter Input :

 

DataType Parameter Description
N/A N/A N/A

 

Method Returns :

The doubleValue() method simply returns the numeric value represented by this object after conversion to type double.

Compatibility Version :

Requires Java 1.0 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of doubleValue() method of Integer class. Basically we ask for an int input from the console, and then we use the scanner to get the value. After that we assign the value to an Integer wrapper class and then get the double equivalent using the doubleValue() method of Integer class.

package com.javatutorialhq.java.examples;

import java.util.Scanner;

import static java.lang.System.*;

/*
 * This example source code demonstrates the use of 
 * doubleValue() method of Integer class.
 */

public class IntegerDoubleValue {

	public static void main(String[] args) {
		// Ask user input
		System.out.print("Enter Desired Value:");
		// declare the scanner object
		Scanner scan = new Scanner(System.in);
		// use scanner to get the value from user console
		int intValue = scan.nextInt();
		// close the scanner object
		scan.close();
		Integer myValue = new Integer(intValue);
		double value = myValue.doubleValue();
		out.println("double Value is " + value);

	}

}

Sample Output :

Running the doubleValue() method example source code of Integer class will give you the following output

Enter Desired Value:1234
double Value is 1234.0

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :