Java formatting string when printing

‮ptth‬s://www.lautturi.com
Java formatting string when printing
/**
 * @author lautturi.com 
 * Java example: format and print string in java
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		int x = 21;
		String str = "hello lau";
		System.out.printf("%s | x = %d\n", str, x);
		
		System.out.printf("%5d\r\n",x);
		System.out.printf("%20s",str);
		
	}
}

output:

hello lau | x = 21
   21
           hello lau
Created Time:2017-09-27 20:15:13  Author:lautturi