Student.java

This commit is contained in:
Neetika23 2023-09-22 22:30:54 +05:30 committed by GitHub
parent 183e213f0e
commit 601d051f32

View File

@ -2,26 +2,15 @@ package com.baeldung.shallowdeepcopy;
class Student { class Student {
private String name; private String name;
private int rollno; private int age;
private School school;
public Student(String name, int rollno) { public Student(String name, int age, School school) {
this.name = name; this.name = name;
this.rollno = rollno; this.rollno = rollno;
this.school = school;
} }
public Student(Student st) {
public String getName() { this(st.getName(), st.getAge(), st.getSchool());
return name; } // standard getters and setters
}
public int getRollno() {
return rollno;
}
public void setRollno(int rollno) {
this.rollno = rollno;
}
public void setName(String name) {
this.name = name;
}
} }