Align Columns with fixed size
http://stackoverflow.com/questions/6000810/printing-with-t-tabs-does-not-result-in-aligned-columns
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
//Scanner scan = new Scanner(System.in);
//String s = scan.next();
//double d = scan.nextDouble();
String prefix1 = "short text:";
String prefix2 = "long texto:";
String msg = "indented";
/*
* The second string begins after 25 characters.
* The dash means that the first string is left-justified.
*/
String format = "%-25s%s%n";
System.out.printf(format, prefix1, msg);
System.out.printf(format, prefix2, msg);
}
}
OUTPUT:
short text: indented
long texto: indented