Answers for "convert double value to int in java"

3

int to double java

Double d= new Double(i);//first way  
Double d2=Double.valueOf(i);//second way  
Posted by: Guest on August-10-2020
2

convert double into integer

class DoubleToInt {
    public static void main( String args[] ) {
        double DoubleValue = 3.6987;
        int IntValue = (int) DoubleValue;
        System.out.println(DoubleValue + " is now " + IntValue);
    }
}
Posted by: Guest on March-02-2021
8

how to change double to int in java

class Scratch{
    public static void main(String[] args){
        double decimal = 5.7;
        System.out.println( (int) decimal );	//casting
        System.out.println( Math.round(decimal * 10) / (double) 10);	//Math.round()
        System.out.println( decimal % 1);	// modulus
        System.out.println( Integer.parseInt( String.valueOf(decimal).substring(0, String.valueOf(decimal).indexOf(".")))); // .substring()
    }
}
Posted by: Guest on February-17-2020

Code answers related to "convert double value to int in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language