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()
}
}
Also in Java:
- check if string is null or empty java
- import java.util.*;
- char array to arraylist java
- get number of items in arraylist java
- java treemap
- java output array lists to file
- join two lists java
- hello world java
- java scanner input int
- how to check the lines in a file java scanner
- how to use spring in java
- make recycler view non scrollable
- java 8 stream group by example
- string to long java
- how to change top of window in java
- java switch display panel
- keep jframe on top
- how to remove components from a JFRame java
- java log base 2
- how to iterate list in java selenium
- how to do 4th root java
- runtime java examples
- Compare integers java sort
- java mysql springboot jpa stackoverflow