格式化字符串并将对象插入字符串

问题描述 投票:0回答:1

[如果我有一行代码,例如String formattedString = String.format("... {}", objectToBeInserted);,我希望将objectToBeInserted插入到{}所在的字符串中,如果我不一定知道objectToBeInserted(因此不能使用%d之类的东西。

如果我有一行代码,例如String formattedString = String.format(“ ... {}”,objectToBeInserted);,我想将objectToBeInserted插入到{}所在的字符串中,我该怎么办...

java string-formatting
1个回答
0
投票

我不完全确定为什么您在问题末尾提到%d时,实际上并没有在您提到的格式字符串中出现它。

© www.soinside.com 2019 - 2024. All rights reserved.