Java - Write code to compare two string for equal using if statement and handle null value

Requirements

Write code to compare two string for equal using if statement and handle null value

Demo

//package com.book2s;

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

    public static boolean equals(String a, String b) {
        if (a == null)
            return b == null;
        else
            return a.equals(b);
    }
}

Related Exercise