美文网首页
String.format

String.format

作者: timar | 来源:发表于2020-01-13 10:21 被阅读0次
// 字符串前面补空格
System.out.println(String.format("%6s", "abc"));
// 字符串后面补空格
System.out.println(String.format("%-6s", "abc"));
// 数字前面补0
System.out.println(String.format("%06d", 123));

   abc
abc   
000123

相关文章

网友评论

      本文标题:String.format

      本文链接:https://www.haomeiwen.com/subject/ydsgactx.html