Reputation: 37078
I am reading this tutorial: link
That get result I am trying to invoke this code:
public static void main(String[] args) throws java.lang.Exception
{
PrintWriter writer = new PrintWriter(System.out);
writer.print(true);
writer.print((int) 123);
writer.print((float) 123.456);
writer.printf(Locale.UK, "Text + data: %1$", 123); //cause of exception
writer.close();
}
I am get exception:java.util.UnknownFormatConversionException: Conversion = '1'
Is it my mistake or tutorial author?
Upvotes: 0
Views: 721
Reputation: 3938
Have a look at the way the string is formatted - http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
It seems that 1$
indicates which argument but you still need a conversion after that - %1$d
Upvotes: 3