title: Java : How to extend a class and use a dot notation on its object
body: <p>Take for example the class JSONObject. </p>
  
  <p>And say I have the following method. </p>
  
  <pre><code>public JSONObject getObjectOrThrow(String name) {
        JSONObject jsonObject = null;
        try {
           jsonObject = JSON.getJSONObject(name);
        } catch (Exception e) {
           System.out.println("JSON_ERROR : " + name);
           e.printStackTrace();
        }
        return jsonObject;
     }
  </code></pre>
  
  <p>How do I extend the <strong>JSONObject</strong> so that I'll end up with a method like. </p>
  
  <pre><code>JSONObject man = new JSONObject("name");
  man.getObjectOrThrow("name");
  </code></pre>
  
  <p>Where "name" is the key to the child node of "man".</p>
  
  <p>Also for reference, what is this called?</p>