求一个java程序:把字符串中的空格用","取代.要求连续的空格,不管多少个都用一个","取代.

2025-12-16 11:39:54
推荐回答(1个)
回答1:

String s = "a c b s d";
String d = s.replaceAll(" +", ",");

System.out.println("source:"+s);
System.out.println("dest:"+d);