title: Scanner loop that is supposed to return each String,
body: <p>I've got a problem with looping a scanner, wich should return EVERY string given as an input unless <code>String != "end"</code>. Here is what I've done so far</p>
  
  <pre><code>private static String fetchString() {
      Scanner scanner = new Scanner(System.in);
      String stringElement = "";
      System.out.println("Write a string");
      while(scanner.hasNextLine()) {
          stringElement = scanner.next();
          if(stringElement == "end") {
              break;
          }
      }
      return stringElement;
  }
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>Write a string
  abc
  abc
  abc
  end
  end
  </code></pre>
  
  <p>Loop, somehow, doesn't understand <code>if(stringElement == "end")</code>, it still wants new word. I can't get it. Where am I making a mistake?</p>