Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

How to avoid duplicates from ArrayList

//How to avoid duplicates from ArrayList
ArrayListTest.java
import java.util.*;
class ArrayListTest
{
	public static void main(String[] args)
	{
		ArrayList al=new ArrayList();
		al.add("Dibya");
		al.add("Dibakar");
		al.add("Jyoti");
		al.add("Renuka");
		al.add("Dibakar");

		System.out.println(al);

		ArrayList al1=new ArrayList(new HashSet(al));
		System.out.println(al1);
	}
}

Output



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext