I am having java code:
public class Test {
public static void main(String[] args) {
Student student = new Student(1,"test");
printId(student);
}
private static void printId(Student obj) {
if(Objects.isNull(obj))
return;
System.out.println("Id: " + obj.getId());
}
}
public class Student {
private int id;
private String name;
public Student(int id, String name) {
this.id = id;
this.name = name;
}
public int getId(){
return id;
}
}
At line System.out.println... sonar is showing that obj can be null but I had already checked for null value.
Is there any way to get rid of this issue?