Java.lang.Double.intValue() Method

Advertisements


Description

The java.lang.Double.intValue() method returns the value of this Double as an int (by casting to type int).

Declaration

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

public int intValue()

Parameters

  • NA

Return Value

This method returns the double value represented by this object converted to type int.

Exception

  • NA

Example

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

package com.tutorialspoint;

import java.lang.*;

public class DoubleDemo {

   public static void main(String[] args) {

     /* returns the double value represented by this object
     converted to type int */
     Double obj = new Double("32.90");
     int i = obj.intValue();
     System.out.println("Value = " + i);
    
     obj = new Double("30.0");
     i = obj.intValue();
     System.out.println("Value = " + i);
   }
}  

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

Value = 32
Value = 30



Advertisements
Advertisements