集册 Java实例教程 使用逗号(,)标志显示带有千位分隔符的数字。

使用逗号(,)标志显示带有千位分隔符的数字。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

978
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用逗号(,)标志显示带有千位分隔符的数字。

public class Main 

{/*来 自 时 代 J a v a 公 众 号 - nowjava.com*/

   public static void main(String[] args) 

   {

      System.out.printf("%,d\n", 58625);

      System.out.printf("%,.2f\n", 58625.21);

      System.out.printf("%,.2f", 12345678.9);

   } 

}