Here you can find the source of addUnique(List
public static <T> boolean addUnique(List<T> list, T item)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static <T> boolean addUnique(List<T> list, T item) { if (!list.contains(item)) { list.add(item);// w w w . j a v a2 s. co m return true; } else { return false; } } }