【发布时间】:2017-04-26 06:39:29
【问题描述】:
我想使用 printf 为字符串赋值。
我想做这样的事情:
String b = printf("Base Price: $%,.2f\n", basePrice);
这可能吗?
(与this one 非常相似的问题,但它在 C 中)。
【问题讨论】:
我想使用 printf 为字符串赋值。
我想做这样的事情:
String b = printf("Base Price: $%,.2f\n", basePrice);
这可能吗?
(与this one 非常相似的问题,但它在 C 中)。
【问题讨论】:
你可以使用String::format:
String b = String.format("Base Price: $%,.2f\n", basePrice);
【讨论】: