Here you can find the source of removeByReference(ArrayList
Parameter | Description |
---|---|
list | a parameter |
object | a parameter |
public static <T> boolean removeByReference(ArrayList<T> list, T object)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /**// ww w. ja va 2 s . com * Removes the given object from the list using reference equality, not equals() * @param list * @param object * @return */ public static <T> boolean removeByReference(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) { list.remove(i); return true; } } return false; } }