Java - Write code to check if two string values are equal

Requirements

Write code to check if two string values are equal

Demo

//package com.book2s;

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

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

        return str1.equals(str2);
    }
}

Related Exercise