Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.HashSet; import java.util.Set; public class Main { /** * Get only the unique elements in a collection */ public static Set<?> getUniqueElements(Collection<?> items) { Set<Object> uniqueSet = new HashSet<>(); for (Object item : items) { uniqueSet.add(item); } return uniqueSet; } }