How to know the Employees.class is null or not using Java Relection?
Example Class: Employees.class
Problem:
- employees.getName();
- value getName is Mikel
- employees is null
- if employess != null is TRUE.
- this class already 'new Employees()'
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
Boolean empty = copyName(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':
java.lang.NullPointerException
How can i check null exception during process on line no.11?
Aucun commentaire:
Enregistrer un commentaire