. . . except that doesn't get you a modifiable list, it just wraps a List interface around the array that's implicitly created by the var-arg, so it's a trick you have to be careful with.
Personally I often end up writing little helpers like:
List<T> list(T... args) {
return new ArrayList<T>(Arrays.asList(args))
}
usually in test code. A built-in List and Map-initialization syntax is really something every decent programming language ought to have.
(Consider using the Google collections library if possible. It already has that in the form of classes like Lists, Maps, etc that provide builders and factory methods.)
Personally I often end up writing little helpers like: List<T> list(T... args) { return new ArrayList<T>(Arrays.asList(args)) } usually in test code. A built-in List and Map-initialization syntax is really something every decent programming language ought to have.