Q:

Java Program to add all the elements of tree set to another tree set

0

Program to add all the elements of tree set to another tree set

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;
public class demo1 
{
 public static void main(String[] args)
 {
  TreeSet<String> tree_set = new TreeSet<String>();
  tree_set.add("C#");
  tree_set.add("C++");
  tree_set.add("Java");
  tree_set.add("HTML");
  tree_set.add("Perl");
  System.out.println("Tree set: " + tree_set);
  
  TreeSet<String> tree_set1 = new TreeSet<String>();
  tree_set1.add("Ruby");
  tree_set1.add("Python");
  System.out.println("Tree set1: "+tree_set1);
   
  tree_set.addAll(tree_set1);
  System.out.println("Tree set: "+tree_set);
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now