How to add ArrayList elements in TreeSet or TreeMap
<p>As we all know, we need to implement Comparable interface and add compareTo() when we work with TreeSet. Not doing so will throw ClassCastException.
Now I have a TreeSet and I need to add ArrayLists as elements of TreeSet.</p>

<p>if we write:</p>

<pre><code>ArrayList al = new ArrayList();
ArrayList al2 = new ArrayList();
ArrayList al3 = new ArrayList();
TreeSet ts = new TreeSet();
ts.add(al);
ts.add(al2);
ts.add(al3);
</code></pre>

<p>It throws ClassCastException.</p>

<p><strong>Question</strong>: How can I add ArrayList istances (not their elements) to a TreeSet or TreeMap?</p>