Java tutorial
//package com.java2s; /* * Copyright (C) 2009 Emweb bvba, Leuven, Belgium. * * See the LICENSE file for terms of use. */ import java.util.List; public class Main { public static <V> void resize(List<V> list, int size) { while (list.size() > size) list.remove(list.size() - 1); while (list.size() < size) list.add(null); } public static <V> boolean add(List<V> list, V v) { if (list.indexOf(v) == -1) { list.add(v); return true; } else return false; } }