public void evaluateCourse() {
// Res res = new Res();
// Connection con = null;
String total = "1,2,33,53";
for(int i = 0;i < total.length() ; i ++){
if(total.charAt(i) != ','){
System.out.println(total.charAt(i));
}
}
}
輸出結果是
#我想要的結果是: 1
2
33
53
伊谢尔伦2017-06-28 09:26:45
先不管用不用String.split()
public void evaluateCourse() {
// Res res = new Res();
// Connection con = null;
String total = "1,2,33,53";
String temp = "";
for(int i = 0;i < total.length() ; i ++){
temp += total.charAt(i);
if(total.charAt(i) == ','){
System.out.println(temp);
temp = "";
}
}
}
再看看用split的
public void evaluateCourse() {
// Res res = new Res();
// Connection con = null;
String total = "1,2,33,53";
String[] temp = aa.split(",");
for(String s : temp) {
System.out.println(s);
}
}