title: Java concatenating various methods (not the method to concatenate strings)
body: <p>When I write a class with several voids:</p>
  
  <pre><code>public class MyObj {
      public void doSomething() { /* does something */ }
      public void doSomethingElse() { /* does something else */ }
      ...
  }
  </code></pre>
  
  <p>I can use the following code:</p>
  
  <pre><code>MyObj myObj = new MyObj();
  myObj.doSomething(); // does something
  myObj.doSomethingElse(); // does something else
  </code></pre>
  
  <p>But if I write the class like this:</p>
  
  <pre><code>public class MyObj {
      public MyObj doSomething() {
          // do something;
          return this;
      }
      public MyObj doSomethingElse() {
          // do something else;
          return this;
      }
  }
  </code></pre>
  
  <p>I can use the following code to accomplish the same task:</p>
  
  <pre><code>MyObj myObj = new MyObj();
  MyObj.doSomething().doSomethingElse(); // does something and does something else.
  </code></pre>
  
  <p>I've seen the 2nd form in JavaScript (jQuery):</p>
  
  <pre><code>$("#myDialog").dialog().focus().mySuperLongNameHomeMadeBullshitFunction().remove();
  </code></pre>
  
  <p>So my question is, in Java, what are the pros and cons of using the concatenating form or the standard? (I'm really not going to change to the second, just curious, as we all are).</p>