急求!!求解答java问题
代码如下,运行结果如图所示。
class Student{
String name;
int age;
String banJi;
String major;
String xueYuan;
public Student(String name,int age,String banJi,String major,String xueYuan){
this.name=name;
this.age=age;
this.banJi=banJi;
this.major=major;
this.xueYuan=xueYuan;
}
@Override
public String toString()
{
return "姓名:"+this.name+", 年龄:"+this.age+", 班级:"+
this.banJi+" ,专业:"+this.major+", 所属学院:"+this.xueYuan;
}
public void Printiofo(){
System.out.println(this.toString());
}
}
public class Practice
{
public static void main(String args[]){
Student student=new Student("张三",19,"2019级2班","网络工程","网络与通信学院");
student.Printiofo();
}
}
public static void main(String[] args) {
Student s = new Student("10086","张三",20,"电气一班","电气工程及其自动化","电气学院");
s.Printinfo();
}
}
class Student{
private String id;
private String name;
private int age;
private String banJi;
private String major;
private String xueYuan;
public Student() {
}
public Student(String id, String name, int age, String banJi, String major, String xueYuan) {
this.id = id;
this.name = name;
this.age = age;
this.banJi = banJi;
this.major = major;
this.xueYuan = xueYuan;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getBanJi() {
return banJi;
}
public void setBanJi(String banJi) {
this.banJi = banJi;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getXueYuan() {
return xueYuan;
}
public void setXueYuan(String xueYuan) {
this.xueYuan = xueYuan;
}
@Override
public String toString() {
return "Student{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", age=" + age +
", banJi='" + banJi + '\'' +
", major='" + major + '\'' +
", xueYuan='" + xueYuan + '\'' +
'}';
}
public void Printinfo(){
System.out.println(this.getId()+","
+ this.getName()+","+this.getAge()+","
+this.getBanJi()+","+this.getMajor()
+","+this.getXueYuan());
}
}