Detecting a particular string value from a file, Java
<p>I'm trying to detect a particular string value in an external txt file. In this case, I am trying to detect %%.</p>

<pre><code>public void read(){
    while(x.hasNext()){
        String a = x.next();
        System.out.println(a);
        if(a == "%%"){
            System.out.println("Found the end");
        }
        else{
            System.out.println("No end");
        }

    }
}
</code></pre>

<p>It is reading x correctly because it prints out the words from the file, but it says "No end" after every word, even the "%%". I'm sure I am making some dumb mistake somewhere, I just can't find it. x looks like this: apple orange %% grapes. Any help with this would be appreciated.</p>
