package org.arpit.java2blog;
public class StringFromatformatDouble {
public static void main(String[] args) {
double d = 2.456534;
System.out.println("Double upto 2 decimal places: "+String.format("%.2f",d));
}
}
double input = 3.14159265359;
System.out.format("double : %.2f", input); // 3.14
System.out.println("double : " + String.format("%.2f", input)); // 3.14
DecimalFormat df = new DecimalFormat("#.00");
package org.arpit.java2blog;
public class PrintfformatDouble {
public static void main(String[] args) {
double d = 2.456534;
System.out.printf("Double upto 2 decimal places: %.2f",d);
}
}
printf(%.2f);
int x = (int) y