Java examples for Object Oriented Design:Objects Utility
Test for equality with Objects.equals
import java.util.Objects; public class Main { public static void main(String[] args) { // Test for equality boolean isEqual = Objects.equals(null, null); System.out.println("null is equal to null: " + isEqual); isEqual = Objects.equals(null, "XYZ"); System.out.println("null is equal to XYZ: " + isEqual); }/*from w w w. ja v a 2 s . c om*/ }