Exercise – Objects.equals() result
There are three classes:
public class A{}
public class B{}
public class Exercise {
private A a;
private B b;
public Exercise(){
System.out.println(java.util.Objects.equals(a, b));
}
public static void main(String... args){
new Exercise();
}
}What is going to be displayed when we run the main() method of the Exercise class? Error? False? True?
Answer
The display will show only one value: True. The reason is that both private fields—a and b—are initialized to null.