File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes printf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "printf" Watch "printf" New topic
Author

printf

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305


0 1.200000 Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4045)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2748)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2702)
at java.util.Formatter.format(Formatter.java:2488)
at java.io.PrintStream.format(PrintStream.java:970)
at java.io.PrintStream.printf(PrintStream.java:871)
at StringExample.main(StringExample.java:10)


My one regret in life is that I am not someone else.
- Woody Allen
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

As you can read here you should use "%d" for integers, and "%f" for both float and double values.

Edit: The 'd' in "%d" refers to number system (decimal), as stated in the API.


The quieter you are, the more you are able to hear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: printf