Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Program to merge duplicates of a List with TreeSet

import java.util.ArrayList;
import java.util.TreeSet;
import java.util.List;
public class Demo {
	public static void main(String[] args) {
		List<String>ls = new ArrayList<String>();
		ls.add("A");
		ls.add("B");
		ls.add("C");
		ls.add("D");
		ls.add("D");
		ls.add("E");
		ls.add("F");
		ls.add("G");
		ls.add("E");
		TreeSet<String>set = new TreeSet<String>();
		set.addAll(ls);
		System.out.println("TreeSet = "+set);
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.