• Post Reply Bookmark Topic Watch Topic
  • New Topic

format specifier issues  RSS feed

 
Ben Phoebi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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



Can I get an explanation for the '$' in the code?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API documentation of class java.util.Formatter explains it. Look under "Argument Index". In short: the number before the $ is the argument number in the list of arguments.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!