如何检查以下对象是否为空白?我有以下课程,如果不检查每个成员,我怎么能检查我的示例类没有任何数据?
public class Test {
public static void main(String[] args){
Sample sample = new Sample();
if(sample!=null){
System.out.println("Object is blank..");
}
}
}
class Sample {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}