How-to articles, tricks, and solutions about DOUBLE

Converting double to integer in Java

To convert a double to an int in Java, you can use the intValue() method of the Double class.

Double decimal formatting in Java

To format a double value as a decimal in Java, you can use the DecimalFormat class from the java.text package. Here's an example of how to use it:

How to nicely format floating numbers to string without unnecessary decimal 0's

To format a floating-point number as a string without unnecessary decimal zeros, you can use the DecimalFormat class from the java.text package. The DecimalFormat class allows you to specify a pattern for formatting numbers as strings.