Java formatted output [Notes]

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:: 2020-10-13_14-09-26.png

Recommended Posts

Java formatted output [Notes]
java notes
[Java] output, variables
Java Generics (Notes)
[Java] Array notes
[Java] Study notes
Java serialization notes
Output Notes document as XML document in Java
About Java log output
[Java] Stream Collectors notes
[Java] Control syntax notes
Java NIO 2 review notes
[Java] Basic method notes
Try scraping using java [Notes]
[Implementation] Java Process class notes
Java Collections Framework Review Notes
Java standard log output sample
[Java] Basic types and instruction notes
[Java] December 28, 2020 will be formatted as December 28, 2021?
[Java] Output by FormatStyle of DateTimeFormatter
[Java] Output multidimensional array / spreadsheet (AOJ⑥ spreadsheet)
Mixed Western calendar output in Java
Log output to file in Java
Notes on signal control in Java
Java
Output PDF and TIFF with Java 8
Notes on Android (java) thread processing
Java
Notes on Java path and Package
Notes on operators using Java ~ String type ~
[Java] How to output and write files!
How to output Java string to console screen
Output Date in Java in ISO 8601 extended format
Output of the book "Introduction to Java"
[Java] Color the standard output to the terminal