Java tutorial
//package com.java2s; import java.lang.reflect.Array; import javax.swing.ListModel; public class Main { public static <T extends Object> T[] extendModel(ListModel selected, T[] extras, Class<T> type) { int selectedSize = selected.getSize(); int extraSize = extras.length; @SuppressWarnings("unchecked") T[] augmented = (T[]) Array.newInstance(type, selectedSize + extraSize); // copy current for (int i = 0; i < selectedSize; i++) { augmented[i] = type.cast(selected.getElementAt(i)); } // augment for (int i = 0; i < extraSize; i++) { augmented[selectedSize + i] = extras[i]; } return augmented; } }