|
|
|
|
|
by akeefer
6178 days ago
|
|
. . . 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. |
|