Make a class printable
<p>When I print the instances of some classes (e.g. <code>ArrayList</code>) to a stream, e.g. <code>System.out.println(</code><i>instance of ArrayList</i><code>)</code>, it doesn't print the reference id (e.g. ArrayList@2144c53d), but the actual values, with some formatting (e.g. [1,2,3,4]). I was wondering how I can do this for my own classes? Do I perhaps have to define some method/implement some interface?</p>
