I want to remove duplicate elements on the list how can you do that.
TCS Interview Question
Q. I want to remove duplicate elements on the list how can you do that.
SOLUTION:-
package i1;
import java.util.HashSet;
import java.util.Set;
public class RemoveDuplicateUsingSet {
public static void main(String[] args) {
Set<Integer> s=new HashSet<>();
s.add(1);
s.add(2);
s.add(2);
s.add(3);
s.add(4);
s.add(5);
s.add(7);
s.add(7);
System.out.println("Set :"+s);
}
}
Comments
Post a Comment