Java - Write code to check if two strings are equal and handle null value

Requirements

Write code to check if two strings are equal and handle null value

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str1 = "book2s.com";
        String str2 = "book2s.com";
        System.out.println(notEquals(str1, str2));
    }/*from w  w w .ja  v  a  2s. c o  m*/

    public static boolean notEquals(String str1, String str2) {
        if (str1 == null) {
            return str2 != null;
        }

        return !str1.equals(str2);
    }

    public static boolean equals(String str1, String str2) {
        if (str1 == null) {
            return str2 == null;
        }

        return str1.equals(str2);
    }
}