title: Java chained/nested method calls
body: <p>I'm working on a JSONObject with multiple sub-JSONObjects.
  Here is the way I fill the content :</p>
  
  <pre><code>myJson.getJSONObject(CAT_NAME).put(VAR_NAME, var)
                            .put(VAR_NAME2, var2)
                            .put(...);
  </code></pre>
  
  <p>A friend told me that it is a very bad practice to use "nested function/method calls" and that I should do it this way :</p>
  
  <pre><code>myJson.getJSONObject(CAT_NAME).put(VAR_NAME, var);
  myJson.getJSONObject(CAT_NAME).put(VAR_NAME2, var2);
  myJson.getJSONObject(CAT_NAME).put(...);
  </code></pre>
  
  <p>From my view, my way is more like an chained method call than a nested one.
    And I don't like the second way because it force the program to get the same object again and again when the put() method already returns it.</p>
  
  <p>Is my case is a "nested function calls" case ?
  Is this dangerous or bad for any reason ? And what are those reasons ?</p>
  
  <p>edit : I don't feel like my question is duplicated. The other question involves chained methods but it mainly talks about c# interfaces.</p>