Java implementation of the contentEquals method
KW.java
class KW
{
    public static void main(String args[])
    {
        String s1="HELLO";
        String s2="WORLD";
        String s3="HELLO";
        String s4="Hello";

        boolean b=s1.contentEquals(s2);
        System.out.println(b);
        b=s1.contentEquals(s3);
        System.out.println(b);
        b=s1.contentEquals(s4);
        System.out.println(b);
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW false true false kodingwindow@kw:~$
Advertisement