I\'m looking for a compact syntax for instantiating a collection and adding a few items to it. I currently use this syntax:
Collection collecti
You could create an utility function:
@SafeVarargs public static List listOf(T ... values) { return new ArrayList(Arrays.asList(values)); }
So you could call it like:
collection = MyUtils.listOf("1", "2", "3");
That way, you can populate a list very easily, and still keep it mutable.