SupportWriter space ↗
← Back to the journal
Basic

How do I convert double value into int value?

To convert double value into an int value we can use type casting or using the Double.intValue() method call. The code snippet below show you how to do it. package org.kodejava.basic; public class DoubleToInt { public static void main(String[] args) { Double numberA = 49.99; System.out.println("numberA = " + numberA); // Converting Double value to […]

DWayan · 02 Jun 2010 · 1 min read

Article by Wayan · Source: Kode Java ↗

To convert double value into an int value we can use type casting or using the Double.intValue() method call. The code snippet below show you how to do it.

package org.kodejava.basic;

public class DoubleToInt {
    public static void main(String[] args) {
        Double numberA = 49.99;
        System.out.println("numberA = " + numberA);

        // Converting Double value to int value by calling
        // the Double.intValue() method.
        int numberB = numberA.intValue();
        System.out.println("numberB = " + numberB);

        // Converting Double value to int value by casting
        // the primitive double value of the Double instance
        int numberC = (int) numberA.doubleValue();
        System.out.println("numberC = " + numberC);

        double numberD = 99.99;
        System.out.println("numberD = " + numberD);

        // Converting double value into int value using
        // type casting
        int numberE = (int) numberD;
        System.out.println("numberE = " + numberE);
    }
}

Comments 0

Share your questions, experiences, or feedback about this article.

No comments yet. Be the first to share your feedback.

← Explore more notes