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));
}
}
}
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));
}
}
}
%s 表示参数值限定为字符串类型,没有格式
%n 表示换行,根本平台的不同而不同。还有一大堆的参数,具体的可以看看 java.util.Formatter 的 API 文档。