例如,C++ 中的 %11.2lf
变成 Java 中的 %11.2f
。
长格式呢?
最佳答案
您可能已经知道,没有必要指定 l
标志。根据the docs ,十进制整数由 d
指定,就像在 C++ 中一样。所以答案就是%d
。
关于java - 用于 String.format() 的 Java 中 %ld 的 C++ 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2011720/
例如,C++ 中的 %11.2lf
变成 Java 中的 %11.2f
。
长格式呢?
最佳答案
您可能已经知道,没有必要指定 l
标志。根据the docs ,十进制整数由 d
指定,就像在 C++ 中一样。所以答案就是%d
。
关于java - 用于 String.format() 的 Java 中 %ld 的 C++ 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2011720/