I'm looking for an algorithm to fill an array of a specific size with the contents of a vararg, repeating the last element of the vararg until the array is full.
public static <T> T[] fillWithRepeat(int length, T... elements) {
// make array of length "length" and fill with contents of "elements"
}
Does anyone know a good algorithm for this?