title: If statement with String comparison fails
body: <p>I really don't know why the if statement below is not executing:</p>
  
  <pre><code>if (s == "/quit")
  {
      System.out.println("quitted");
  }
  </code></pre>
  
  <p>Below is the whole class.</p>
  
  <p>It is probably a really stupid logic problem but I have been pulling my hair out over here not being able to figure this out.</p>
  
  <p>Thanks for looking :)</p>
  
  <pre><code>class TextParser extends Thread {
      public void run() {
          while (true) {
              for(int i = 0; i &lt; connectionList.size(); i++) {
                  try {               
                      System.out.println("reading " + i);
                      Connection c = connectionList.elementAt(i); 
                      Thread.sleep(200);
  
                      System.out.println("reading " + i);
  
                      String s = "";
  
                      if (c.in.ready() == true) {
                          s = c.in.readLine();
                          //System.out.println(i + "&gt; "+ s);
  
                          if (s == "/quit") {
                              System.out.println("quitted");
                          }
  
                          if(! s.equals("")) {
                              for(int j = 0; j &lt; connectionList.size(); j++) {
                                  Connection c2 = connectionList.elementAt(j);
                                  c2.out.println(s);
                              }
                          }
                      }
                  } catch(Exception e){
                      System.out.println("reading error");
                  }
              }
          }
      }
  }
  </code></pre>