Usefull Generics
This is quite useful:
asList(a,b,c,d,e);
public static <T> List<T> asList(T... obj) {
List<T> result = new ArrayList<T>();
Collections.addAll( result, obj );
return( result );
}
asList(a,b,c,d,e);
3 Comments:
or Arrays.asList( new Foo[] { a, b, c } );
I used to use that.. then I also added asSet, and dropped the Array creation.
Looks like Arrays.asList(T... ) takes varargs already ...
Post a Comment
<< Home