Here you can find the source of add(List
Parameter | Description |
---|---|
current | a parameter |
toAdd | a parameter |
public static <T> void add(List<T> current, T toAdd)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**/*from w w w . j ava 2 s .co m*/ * Generic addition of an item to a List (without repeats) -- used to * accommodate ObservableLists in front-end * * @param current * @param toAdd */ public static <T> void add(List<T> current, T toAdd) { for (int i = 0; i < current.size(); i++) { if (current.get(i).equals(toAdd)) { current.remove(i); i--; } } current.add(toAdd); } }