我正在阅读本教程:链接
我试图调用以下代码的结果:
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();
}我有例外:java.util.UnknownFormatConversionException: Conversion = '1'
是我的错误还是教程作者?
发布于 2014-07-02 11:35:56
查看字符串的格式化方式- http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax。
1$似乎指明了哪个参数,但在此之后仍然需要进行转换- %1$d。
https://stackoverflow.com/questions/24529720
复制相似问题