📜  java printf 选项卡 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:27.908000             🧑  作者: Mango

代码示例1
String prefix1 = "short text:";
String prefix2 = "looooooooooooooong text:";
String msg = "indented";
/*
* The second string begins after 40 characters. The dash means that the
* first string is left-justified.
*/
String format = "%-40s%s%n";
System.out.printf(format, prefix1, msg);
System.out.printf(format, prefix2, msg);

result:
short text:                             indented
looooooooooooooong text:                indented