string.replaceAll("\\s+"," ");
public class Test {
public static void main(String[] args) {
String str ="A B C ";
System.out.println(str);
System.out.println(str.replaceAll(" ", " "));
}
}
public class Demo {
public static void main(String[] args) {
String s = "asdkjhkjg";
String ss = "";
for (int i = 0; i < s.length(); i++) {
ss = s.charAt(i) + " ";
System.out.print(ss);
}
}
}
replaceAll(" +"," ");
不懂什么意思,举个例子