• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Formatting with printf() and format

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

i am beginner in java and preparing for SCJP 1.6, i am following K&B as a study guide , i got stuck in the topic formatted printf and format.


Output:
> (123)<
>012,345<
>+12345 <
>false + -123<


In the above code at line 1 what does 1$ refers to although we have only one argument i1, what does "7d" does eventhough changing the numeric value is not making any difference in the output

In line 2 how does %0 differs from %1$ and how does separator(,) works here

Line 3 giving both + and - results only in + as output

Thanks in advance
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not to be too flippant about it, I think the answers you seek lie here, JavaDocs
Dealing with the Format String Syntax.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic