java怎么把一个类中的变量全部添加到一个动态数组里
importjava.io.*;publicclassPatientimplementsSerializable{/****/privatestaticfinallong...
import java.io.*;
public class Patient implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
public int id;
public String name;
public int yearOfBirth;
public Patient(int id,String name,int yearOfBirth) {
System.out.println("Please provide your id,name,and yearOfBirth");
}
public Patient() {}
public void setId(int id) {
this.id=id;
}
public void setName(String name) {
this.name=name;
}
public void setYearOfBirth(int yearOfBirth) {
this.yearOfBirth=yearOfBirth;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getYearOfBirth() {
return yearOfBirth;
}
public String toString() {
return "The patient "+id+"'s detial is"+ id+name+yearOfBirth;
}
}
write a new classshould store all the patients’ information using an ArrayList. 展开
public class Patient implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
public int id;
public String name;
public int yearOfBirth;
public Patient(int id,String name,int yearOfBirth) {
System.out.println("Please provide your id,name,and yearOfBirth");
}
public Patient() {}
public void setId(int id) {
this.id=id;
}
public void setName(String name) {
this.name=name;
}
public void setYearOfBirth(int yearOfBirth) {
this.yearOfBirth=yearOfBirth;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getYearOfBirth() {
return yearOfBirth;
}
public String toString() {
return "The patient "+id+"'s detial is"+ id+name+yearOfBirth;
}
}
write a new classshould store all the patients’ information using an ArrayList. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询