aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes help me understand this small code please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help me understand this small code please" Watch "help me understand this small code please" New topic
Author

help me understand this small code please

Haythem Ben Yahia
Greenhorn

Joined: Nov 29, 2012
Posts: 14
hi,
i found this code in a practice exam but even i tested it in Eclipse, i didn't find how it works.
please can someone explain me what this 1$+10d %.....

help please!!!
Guy Buyle
Greenhorn

Joined: Nov 30, 2012
Posts: 6
Hi,

The following line contain print formattings:

System.out.printf("%1$+10d %2$010d ", x, MAX_VALUE - y);

Format specifiers begin with a percent sign (%) and end with a converter. The converter is a character indicating the type of argument to be formatted. In between the percent sign (%) and the converter you can have optional flags and specifiers.

%[argument_index$][flags][width][.precision]conversion

The optional argument_index is a decimal integer indicating the position of the argument in the argument list. The first argument is referenced by "1$", the second by "2$", etc.

The optional flags is a set of characters that modify the output format. The set of valid flags depends on the conversion.

The optional width is a non-negative decimal integer indicating the minimum number of characters to be written to the output.

The optional precision is a non-negative decimal integer usually used to restrict the number of characters. The specific behavior depends on the conversion.

The required conversion is a character indicating how the argument should be formatted. The set of valid conversions for a given argument depends on the argument's data type.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me understand this small code please
 
Similar Threads
Constructors
Switch case with static variable
Static????????????
MissingFormatWidthException
BubbleSort on Matrix