Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "printf" Watch "printf" New topic


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(
at java.util.Formatter$FormatSpecifier.printInteger(
at java.util.Formatter$FormatSpecifier.print(
at java.util.Formatter.format(
at StringExample.main(

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

Joined: Jun 19, 2010
Posts: 825

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.
Have you tried LearnNowOnline?
subject: printf