I am trying to remove duplicate values by converting an array to an arraylist and then further converting the arraylist to a Hashset. As we know hashsets do not contain any duplicate values. But i am not getting any output. I am implementing this technique because I want to avoid using a for loop .
import java.util.*;
public class RemoveDupliucate {
public static void main(String[] args) {
int a[]= {1,2,1,3,2,15,4,6,4};
List l=Arrays.asList();
TreeSet<Integer> m=new TreeSet(l);
for(Integer i:m)
{
System.out.print(i);
}
}
i am not getting any output.