Java字符串格式化输入

两种方式
System.out.println(MessageFormat.format("{0}-{1}",1,2));
System.out.println(String.format("%d-%d",1,2));

 注意如果是4位以上的数比如1234,MessageFormat显示的是1,234.需要使用{0,number,#}格式化

原文地址:https://www.cnblogs.com/zhaogaojian/p/9748865.html