Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    /**
     * 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;
    }
}