Reputation: 151
I saw some code with something like
String.format("%3d\t%s" , stuff, stuff).
What does the stuff in the quotation marks mean? I know \t is just a tab, but I do not know what the %'s and other things are.
Also, are there any more of those types of symbols that can be used for formatting Strings?
Upvotes: 0
Views: 1627
Reputation: 27528
String.format takes a printf format string. Java's format is documented in the JDK documentation for java.lang.String.
The format string you are using breaks down as follows:
Upvotes: 1
Reputation:
I don't know much about Java but in c c++ means an 3 spaces integer first(%3d) and a string (%s), the values after commas are the variables that take their positions. Maybe a variant of printf method
Upvotes: 0