How to format a double in Java

In Java, we can use String.format or DecimalFormat to format a double, both support Locale based formatting. 1. String.format .2%f For String.format, we can use %f to format a double, review the following Java example to format a double. FormatDouble1.java package com.mkyong.io.utils; import java.util.Locale; public class FormatDouble1 { public static void main(String[] args) { String …

Read more