本帖最后由 聆听 于 2012-10-28 18:04 编辑
以前面试总结的,给大家分享下:
//去除逗号
String str = "A,B,C,D,E,F";
String[] reStr1 = str.split(",");
for (int i = 0; i < reStr1.length; i++) {
System.out.print(reStr1);
}
//去除逗号
String reStr2 = str.replace(",", "");
System.out.println("\n"+reStr2);
//截取ABCD
String reStr3 = reStr2.substring(0,4);
System.out.println(reStr3);
//去空格
String str2 = "H ua ng B o";
String reStr4 = str2.replace(" ","");
System.out.println(reStr4);
|