Results 1 to 4 of 4
- 08-26-2012, 10:02 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 9
- Rep Power
- 0
Using Format Specifiers as Text in printf()
Hi,
I want a System.out.printf() to display " ... a long must be formatted with %d, not %f:\n" +
"myLong == %d works;\n", myLong);
and have it ignore the %d and %f on the first line.
How can I do this or do I need to put the first line in a println() instead of a printf()?
System.out.println(" ... a long must be formatted with %d, not %f::\n" +
"myLong == %f throws an Exception.");
Thanks
- 08-26-2012, 10:15 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Re: Using Format Specifiers as Text in printf()
I closed your other (duplicate) thread; please start only one thread per problem. Maybe it helps to know that a double percent sign (%%) produces a single percent sign on the output.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 08-27-2012, 04:32 PM #3
Member
- Join Date
- Aug 2012
- Posts
- 9
- Rep Power
- 0
Re: Using Format Specifiers as Text in printf()
Thanks for the reply Jos.
2 Things.
1. The other thread I accidentally submitted without a title: I didn't know how to remove the post or edit it to fix the title so I submitted it again. Tell me how and I won't do it again.
2. Thanks for the help; %%f does what I want it To :D
- 08-27-2012, 05:28 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
printf VS printWriter.printf
By Mapisto in forum New To JavaReplies: 14Last Post: 01-20-2012, 12:29 PM -
Using printf without specifiers
By FAkamo in forum New To JavaReplies: 1Last Post: 10-17-2011, 08:46 AM -
system.out.printf versus system.out.format
By bigsonny in forum New To JavaReplies: 10Last Post: 06-21-2011, 10:40 PM -
Text format in JTextArea
By goodlily in forum AWT / SwingReplies: 4Last Post: 04-10-2011, 11:57 PM -
Format Specifiers
By Cass29 in forum New To JavaReplies: 3Last Post: 12-20-2009, 03:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks