Java tutorial
//package com.java2s; import java.util.List; public class Main { public static <T> void addNotExist(List<T> list, int idx, T element) { if (!list.contains(element)) { list.add(idx, element); } } }