public LinkedList<String> removeDuplicates(LinkedList<String> linkedList)
{
Set set = new HashSet();
List newList = new ArrayList();
for (Iterator iter = linkedList.iterator(); iter.hasNext(); )
{
Object element = iter.next();
if (set.add(element))
{
newList.add(element);
}
}
linkedList.clear();
linkedList.addAll(newList);
return linkedList;
}
The above code snippet is for removing duplicated and repeated values from ArrayList in Java.
#java #arraylist #array #duplicated #repeated
#cesarnog
#java #arraylist #array #duplicated #repeated
#cesarnog
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.