01: import java.util.*;
02: 
03: public class Utils
04: {
05:    public static <E> void fill(ArrayList<E> a, E value, int count)
06:    {
07:       for (int i = 0; i < count; i++)
08:          a.add(value);
09:    }
10: 
11:    public static <E, F extends E> void append(ArrayList<E> a, 
12:          ArrayList<F> b, int count)
13:    {
14:       for (int i = 0; i < count && i < b.size(); i++)
15:          a.add(b.get(i));
16:    }
17: 
18:    public static <E extends Comparable<? super E>> 
19:          E getMax(ArrayList<E> a)
20:    {
21:       E max = a.get(0);
22:       for (int i = 1; i < a.size(); i++)
23:          if (a.get(i).compareTo(max) > 0) max = a.get(i);
24:       return max;
25:    }
26: 
27:    public static <E> void fillWithDefaults(ArrayList<E> a, 
28:          Class<? extends E> cl, int count) 
29:          throws InstantiationException, IllegalAccessException
30:    {
31:       for (int i = 0; i < count; i++)
32:          a.add(cl.newInstance());
33:    }
34: }