Return to Snippet

Revision: 7267
at July 16, 2008 06:43 by narkisr


Initial Code
public class CollectionInitUtils {

    public static <T> T[] ar(final T... ts) {
        return ts;
    }

    public static <T> Set<T> set(final T... ts) {
        return new HashSet<T>(Arrays.asList(ts));
    }

    public static <K, V> Map<K, V> zipMap(final K[] keys, final V[] values) {
        final Map<K, V> res = new HashMap<K, V>();
        for (int i = 0; i < keys.length; i++) {
            res.put(keys[i], values[i]);
        }
        return res;
    }
}

Initial URL

                                

Initial Description
This is a collection of useful static initializers of Java arrays, lists and maps.

Initial Title
Java Collection utilities

Initial Tags
java

Initial Language
Java