Here you can find the source of addIfAbsent(Collection super T> c, T item)
public static <T> boolean addIfAbsent(Collection<? super T> c, T item)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static <T> boolean addIfAbsent(Collection<? super T> c, T item) { return !c.contains(item) && c.add(item); }// w ww .j av a 2 s . co m }