title: Using readline() and split()
body: <p>The code below is mostly self explanatory. However, I am having trouble in two cases:</p>
  
  <ol>
  <li><p>The <code>while</code> loop does not exit even with the command line is left blank.</p></li>
  <li><p>If the input is <code>test t1</code> the <code>key</code> variable is supposed to be "test" (using <code>System.out.println(key)</code>) does that, but, it still doesn't enter the <code>if</code> condition for some reason.   </p>
  
  <pre><code>String[] broken_text = null; String text = "";
  BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  while((text = reader.readLine()) != null) {     
    broken_text =    text.split(" ");
    String first_key = broken_text[0];    
    if (first_key == "test") {
          //some statements    
     }
  }
  </code></pre></li>
  </ol>
  
  <p>I am not sure why this is happening, any help regarding the same will be much appreciated.</p>