public static void main(String[] args) {
String s = "a,b,c";
String [] arr = s.split(",");
for (int i = 0; i < arr.length; i++) {
System.out.print(" "+arr[i]);
}
}
这是针对普遍的字符串,如果是特定的字节还可以用
public static void main(String[] args) {
String s = "a,b,c";
char [] arr = s.toCharArray();//s.split(",");
for (int i = 0; i < arr.length; i++) {
char a = arr[i];
if(!",".equals(String.valueOf(a))){
System.out.print(" "+arr[i]);
}
}
}
温馨提示:答案为网友推荐,仅供参考