[英]NullPointerException - check null on class
How to know the Employees.class is null or not using Java Relection?如何知道Employees.class 是否为空或不使用Java Reelection?
Example Class: Employees.class示例类:Employees.class
Problem:问题:
Employees.Class员工.班级
public class Employees{
private Long id;<br>
private String kodStuff;<br>
private String Name;<br>
//Getter and Setter<br>
}
Example Process Method:示例处理方法:
public void check(){
Employees employees = new Empoyees;
employees.setName("Mikel");
employees.setKodStuff("KL370");
//employees not save yet and process redirect check value of Name wuth return boolean
Boolean empty = checkName(employees);
}
public boolean checkName(Employees employees){
boolean notNull = false;
if(employees !=null && StringUtils.isNotBlank(employees.getName())){ // this is line 11
notNull = true;
}
return notNull;
}
Throws exception at line no '11':在第 11 行抛出异常:
java.lang.NullPointerException
How can i check null exception during process on line no.11?如何在第 11 行的过程中检查空异常?
尝试通过执行以下操作检查employees.getName()
是否为空:
employees.getName() != null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.