I find myself re-implementing List creation method. But I'm sure that it is already implemented in some widely used library (if not in java itself). So my question is: Which useful library to include, to get functionality of following code:
public static <T> List<T> buildList(T... args) {
ArrayList<T> list = new ArrayList<T>();
for (T arg : args)
{
list.add(arg);
}
return list;
}
EDIT: Already found what i was looking for: http://code.google.com/p/google-collections/ I just import statically:
import static com.google.common.collect.Lists.newArrayList;
and use:
methodThatTakesArray(newArrayList("fst", "snd", "lst"));