Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /** * Adds the object to the list if it does not already exist * @param list * @param object * @return */ public static <T> boolean containsByReference(ArrayList<T> list, T object) { if (list == null) return false; int size = list.size(); for (int i = 0; i < size; i++) { if (list.get(i) == object) { return true; } } return false; } }