我有一个物体叫 Person
。
它有几个属性;
int id;
String name;
我设置了一个像 Person p = new Person(1,"Joe");
这样的人物对象。
1)我需要检查对象是否为空; 下面的表达式是否正确;
if (person == null){
}
Or
if(person.equals(null))
2)我需要知道 ID 是否包含 Int。
if(person.getId()==null){}
但是 java 不允许,我怎么做这个检查?