Program not noticing when the string is equal to a specific string : <p>I've been trying to create a program that censors a word but I was having difficulty with that so I tried going back to some of the fundamental code and testing it and I am coming across an odd result.</p>

<pre><code>import java.util.Scanner;

public class TextCensor
{
public static void main(String[] args)
{
        String input;
        Scanner keyboard = new Scanner(System.in);
        input = keyboard.nextLine();
        int length = input.length() - 1;

        if (length + 1 &gt;= 3)
        {

            for (int i=0; i&lt;(length - 1); i=i+1 )
            {
                char first = input.charAt(i);
                char second = input.charAt(i+1);
                char third = input.charAt(i+2);

                String censorCheck = "" + first + second + third;

                if (censorCheck == "tag")
                {
                    System.out.println("success");
                }
                else
                {
                    System.out.println(censorCheck);
                }
            }
        }
        else
        {
            System.out.println(input);
        }
}
}
</code></pre>

<p>If I input the string "adtag" I will obtain the following output:</p>

<pre><code>adt
dta
tag
</code></pre>

<p>yet "success" will never be printed despite the fact that I have printed a censorCheck that is equal to "tag".</p>
