「Java入門」Objectsクラスのequalsのサンプル

Javaコード
package study;

import java.util.Objects;

public class ObjectEqualsDemo {

public static void main(String[] args) {
String strAA = null;
String strBB = “this is sample”;
String strCC = null;
String strDD = “this is sample”;

System.out.println(Objects.equals(strAA, strBB));
System.out.println(Objects.equals(strAA, strCC));
System.out.println(Objects.equals(strBB, strDD));

}

}

結果
false
true
true