Compare Strings in Java
The String class provides a method equals() to compare string values. The double equal sign == only compares the references, not the values. Here “a” and “b” are pointing to two different String objects. The equals() method will check the …