Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issues in understanding the basics of the output

 
Rachit Kumar Saxena
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever I write:
printf("%3.1d",9);

I get:
9

but printf("%3.2d",9);

Gives:
09 as output.Why?Could anyone explain with the basics?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15438
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the documentation for printf, which explains exactly what the format string means.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic