I have one problem.
let's say i have a model
public class Student{
private int id;
private String name;
//getters and setters
}
Then i need to create 2 objects in different classes using Student model. In first class i need to create object with 2 fields, in second class with just one field.
public class ClassA{
Student student = new Student();
student.setId(id);
student.setName(name);
}
and
public class ClassB{
Student student = new Student();
student.setId(id);
}
Then in second class even though i do not use second field, it is still being added as null.
How can I avoid this?