Trouble in using scanner in java : <p>Scanner class doesn't work how I expected.</p>

<pre><code>Scanner in = new Scanner(System.in); // input: total

String str = in.nextLine();          // total
System.out.println(str);             // total
System.out.println(str == "total");  // false
System.out.println(str != "total");  // true
</code></pre>

<p>I expected line 5 being true, but the above code is what i got.</p>

<p>How should I do for (str == "total") becomes true?</p>
