日期:2014-05-20 浏览次数:20609 次
package csdn;
public class Student {
private String name;
private String num;
private String score;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getScore() {
return score;
}
public void setScore(String score) {
this.score = score;
}
public static void main(String[] args) {
String str = "name=zhangsan;num=3;score=123";
String[] datas = str.split(";");
Student stu = new Student();
for(int i=0;i<datas.length;i++) {
String[] str4stu = datas[i].split("=");
if(str4stu[0]!=null&&str4stu[0].equals("name")) {
stu.setName(str4stu[1]);
}else if(str4stu[0]!=null&&str4stu[0].equals("num")) {
stu.setNum(str4stu[1]);