import java.util.Locale;
public class PrintfExamples {
public static void main(String[] args) {
// flags
System.out.printf("num is %d\n", 5000000);
System.out.printf("float is %f\n", 1.23456789);
System.out.printf("float is %.3f\n", 1.23456789);
System.out.printf("float is %.1f\n", 1.23456789);
System.out.printf("float is %.0f\n", 1.23456789);
System.out.printf("float is %-20f!\n", 1.23456789);
}
}
/*num is 5000000
float is 1.234568
float is 1.235
float is 1.2
float is 1
float is 1.234568 */
|