Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems that you are trying to implement composition and at the same time extending the tree set, but that is not a good practice, you either use composition and implement the Set interface (backend with a TreeSet) or extends the tree set</p> <p>Extending the TreeSet</p> <pre><code> class MySet&lt;E&gt; extends TreeSet&lt;E&gt; { public void union(Set&lt;E&gt; s){ addAll(s); } public void intersection(Set&lt;E&gt; s){ retainAll(s); } } </code></pre> <p>using composition</p> <pre><code> class MySet&lt;E&gt; implements Set&lt;E&gt; { private TreeSet&lt;E&gt; set; public MySet(TreeSet&lt;E&gt; set) { this.set = new TreeSet&lt;&gt;(set); } public void union(Set&lt;E&gt; s){ set.addAll(s); } public void intersection(Set&lt;E&gt; s){ set.retainAll(s); } @Override public int size() { return set.size(); } @Override public boolean isEmpty() { return set.isEmpty(); } @Override public boolean contains(Object o) { return set.contains(o); } @Override public Iterator&lt;E&gt; iterator() { return set.iterator(); } @Override public Object[] toArray() { return set.toArray(); } @Override public &lt;T&gt; T[] toArray(T[] a) { return set.toArray(a); } @Override public boolean add(E e) { return set.add(e); } @Override public boolean remove(Object o) { return set.remove(o); } @Override public boolean containsAll(Collection&lt;?&gt; c) { return set.containsAll(c); } @Override public boolean addAll(Collection&lt;? extends E&gt; c) { return set.addAll(c); } @Override public boolean retainAll(Collection&lt;?&gt; c) { return set.retainAll(c); } @Override public boolean removeAll(Collection&lt;?&gt; c) { return set.removeAll(c); } @Override public void clear() { set.clear(); } @Override public boolean equals(Object o) { return set.equals(o); } @Override public int hashCode() { return set.hashCode(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload