Java tutorial
import java.util.Iterator; import java.util.TreeSet; public class Main { public static void main(String[] args) { TreeSet<Integer> treeone = new TreeSet<Integer>(); TreeSet<Integer> treetwo = new TreeSet<Integer>(); treeone.add(12); treeone.add(13); treeone.add(14); treetwo.add(15); treetwo.add(16); treetwo.add(17); // adding treetwo to treeone treeone.addAll(treetwo); Iterator<Integer> iterator = treeone.iterator(); while (iterator.hasNext()) { System.out.print(iterator.next()); } } }