by @kodeazy

How to remove decimal part from java number?

Home » java » How to remove decimal part from java number?
  • we can type cast to convert double value to int in java Syntax is:

    	int decimalRemovedValue=(int)(decimalValue);

    Consider below example:

    class DoubleToInt{
    public static void main(String args []){
    	double decimalValue=2.5;
    	int decimalRemovedValue=(int)(decimalValue);
    	System.out.println(decimalRemovedValue);		
    
    }
    }

    Output:

    2