LinkedHashSet Set Within Set
<p>Using x2 = [x₁,[1,x₁]] as a task,</p>

<p>I am having trouble getting my output to be... </p>

<p>x2 = [[1,2,3,4,5,6,7,8],[1,[1,2,3,4,5,6,7,8]]];</p>

<p>when i print out the set i get...</p>

<p>[[1, 2, 3, 4, 5, 6, 7, 8], [1]]</p>

<p>i am sure its because of the no duplicates in linkedhashsets but thats the output i need.</p>

<p>I tried getting it to work with tree sets but get the same output.</p>

<p>Any help would be much appreciated. </p>

<p>Thanks in advance.</p>

<pre><code>    public class outputSets 
    {
      public static void main(String args[]) 
      {
       LinkedHashSet&lt;Integer&gt; x0 = new LinkedHashSet&lt;Integer&gt;();
       LinkedHashSet&lt;Integer&gt; x00 = new LinkedHashSet&lt;Integer&gt;();
       LinkedHashSet&lt;Integer&gt; x1 = new LinkedHashSet&lt;Integer&gt;();
       LinkedHashSet&lt;LinkedHashSet&lt;Integer&gt;&gt; x2a = new                                      
                       LinkedHashSet&lt;LinkedHashSet&lt;Integer&gt;&gt;();
       LinkedHashSet&lt;LinkedHashSet&lt;Integer&gt;&gt; x2b = new     
                       LinkedHashSet&lt;LinkedHashSet&lt;Integer&gt;&gt;();

    x0.add(8);
    x00.add(1);

    x1.add(1);
    x1.add(2);
    x1.add(3);
    x1.add(4);
    x1.add(5);
    x1.add(6);
    x1.add(7);
    x1.addAll(x0);

    x2a.add(x00);
    x2a.add(x1);

    x2b.add(x1);
    x2b.addAll(x2a);

    System.out.println(x2b);
    }
}
</code></pre>
