Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.out.println("Example 1 : Field Width");
- double number =12345.6789;
- System.out.printf("the number is:%20f\n\n", number);
- //20 - field width
- System.out.println("Example 2 : Field Width with limited field");
- double number2 = 12345.6789;
- System.out.printf("The number is:%1f\n\n",number2);
- System.out.println("Example 3 : Field Width With Rounding");
- double num3 = 12345.6789;
- System.out.printf("num3 is:%12.2f\n\n", num3);
- System.out.println("Example4 : Field Width with integers");
- int num4 = 200;
- System.out.printf("The number is: %6d\n", num4);
- System.out.println("Example5 : Columns");
- double n1 = 127.899, n2 = 3465.148, n3 = 3.776;
- System.out.printf("%12.2f\n", n1);
- System.out.printf("%12.2f\n", n2);
- System.out.printf("%12.2f\n", n3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement