format Basics Coco et al. May be universal in any language. Java formatted output memo reference. http://www.ne.jp/asahi/hishidama/home/tech/java/formatter.html
It has nothing to do with formatted output, but you need to be careful about memory. Since it is java, there is a memo eating so that it is not safe.
demojava/demo15/Demo15.java
package demojava.demo15;
public class Demo15 {
public static void main(String[] args) {
Integer abc = 123;
for(int i = 0 ; i <10 ; i++){
System.out.println(String.format("println = %0" + (i + abc.toString().length() + 1) +"d", abc));
System.out.format("format = %0" + (i + abc.toString().length() + 1) +"d\n", abc);
}
}
}
Execution result::
Recommended Posts