window.ENTITIES={'/api/snippets/java/java%20-%20remove%20trailing%20zeros%20from%20double%20(while%20printing)':[{"result":true,"message":null,"batch":{"type":"java","name":"java - remove trailing zeros from double (while printing)","items":[{"id":"1b8mBp","type":"java","name":"Java - remove trailing zeros from double (while printing)","content":"// import java.text.DecimalFormat;\n\nDecimalFormat format = new DecimalFormat(\"0.#################\");\n\nSystem.out.println(format.format(0.0)); // 0\nSystem.out.println(format.format(1.0)); // 1\nSystem.out.println(format.format(2.0)); // 2","source":"","author":{"id":"YoWl70","name":"TylerH","avatar":"1629142164198__YoWl70__w40px_h40px.jpg","points":448,"role":"BASIC"},"creationTime":1692901509000,"updateTime":null,"removalTime":null},{"id":"j8dl9j","type":"java","name":"Java - remove trailing zeros from double (while printing)","content":"import java.text.DecimalFormat;\n\npublic class Program {\n\n public static void main(String[] args) {\n\n DecimalFormat format = new DecimalFormat(\"0.#################\");\n\n System.out.println(format.format(0.0)); // 0\n System.out.println(format.format(1.0)); // 1\n System.out.println(format.format(2.0)); // 2\n \n System.out.println(format.format(3)); // 3\n System.out.println(format.format(3.1)); // 3.1\n System.out.println(format.format(3.15)); // 3.15\n \n System.out.println(format.format(3.00)); // 3\n System.out.println(format.format(3.10)); // 3.1\n System.out.println(format.format(3.15)); // 3.15\n }\n}","source":"","author":{"id":"zaL9no","name":"Yusef-Ewing","avatar":"1629030497036__zaL9no__w40px_h40px.png","points":479,"role":"BASIC"},"creationTime":1692901515000,"updateTime":1692901520000,"removalTime":null}]}}]};