Results 1 to 1 of 1
Thread: Demonstration of printf() method
-
Demonstration of printf() method
Java Code:public class PrintfDemo { public static void main(String args[]) { System.out.println("Here are some numeric values " + "in different formats.\n"); System.out.printf("Various integer formats: "); System.out.printf("%d %(d %+d %05d\n", 3, -3, 3, 3); System.out.println(); System.out.printf("Default floating-point format: %f\n", 1234567.123); System.out.printf("Floating-point with commas: %,f\n", 1234567.123); System.out.printf("Negative floating-point default: %,f\n", -1234567.123); System.out.printf("Negative floating-point option: %,(f\n", -1234567.123); System.out.println(); System.out.printf("Line-up positive and negative values:\n"); System.out.printf("% ,.2f\n% ,.2f\n", 1234567.123, -1234567.123); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
Demonstration of autobox and unbox
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:09 PM -
TreeSet Demonstration
By Java Tip in forum java.langReplies: 0Last Post: 04-15-2008, 07:34 PM -
Demonstration of heaps
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:50 PM -
Ftp client demonstration
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:11 PM -
printf
By Jack in forum New To JavaReplies: 2Last Post: 07-04-2007, 04:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks