插值模拟(字符串格式)

时间:2014-10-10 00:26:30

标签: java format

这是一个例子:

int n1 = 20;
int n2 = 40;
String output = String.format("Some guy is **%d** years old while the other is **%d** ", n1, n2);
System.out.println(output);

为什么这不起作用?

1 个答案:

答案 0 :(得分:0)

我发现它在我测试时效果很好,它将打印如下:

  Some guy is 20 years old while the other is 40