System.out.printf("%-7s %s%n", str, str.matches(regex));请问一下, "%-7s %s%n" 这个东西是关于格式 设置的,我看不懂 其中的意思!!帮忙解释一下这里原程序
public class Test {    public static void main(String[] args) {
        String[] strs = {
                "abc1232",  "wwwadsf",
                "awwwfas",  "wwadfsf",
                "", "ww", " ", "www"
            };
        String regex = "(?:(?!^www).)*";
        for(String str : strs) {
            System.out.printf("%-7s %s%n", str, str.matches(regex));
        }
    }
}

解决方案 »

  1.   

    这是 JDK 5 增加的仿 C 语言 printf 的格式,主要使用了变参这个特性。%-7s 表示参数值限定为字符串类型,占 7 个宽度,- 表示左对齐
    %s 表示参数值限定为字符串类型,没有格式
    %n 表示换行,根本平台的不同而不同。还有一大堆的参数,具体的可以看看 java.util.Formatter 的 API 文档。