title: Passing ByteArrayOutputStream into the Constructor of DataOutputStream
body: <p>I understand that this can be done using wrapper pattern, but i am having a hard time understanding, how does the following code work.</p>
  
  <pre><code>ByteArrayOutputStream bytearray = new ByteArrayOutputStream();
  DataOutputStream os = new DataOutputStream(bytearray);
  </code></pre>
  
  <p>passing <code>ByteArrayOutputStream</code> reference into the constructor of <code>DataOutputStream</code> means that the <code>DataOutputStream</code> gets converted to <code>ByteArrayOutputStream</code>, but how?</p>
  
  <p>After this, <code>os.writeUTF("String");</code>
  How does <code>DataOutputStream</code> convert to <code>ByteArrayOutputStream</code>.</p>
  
  <p>What is happening behind the scenes? Can somebody please explain the details.</p>