Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2013
 *
 * 52North Initiative for Geospatial Open Source Software GmbH
 * Contact: Andreas Wytzisk
 * Martin-Luther-King-Weg 24
 * 48155 Muenster, Germany
 * info@52north.org
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

import java.util.Collections;
import java.util.HashMap;

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    /**
     * @param entries the <i>final</i> set of entries to add to the newly created <i>unmodifiable</i> map
     * @return an <i>unmodifiable</i> map with all given entries
     */
    public static <K, V> Map<K, V> map(final Entry<K, V>... entries) {
        final HashMap<K, V> map = new HashMap<K, V>(entries.length);
        for (final Entry<K, V> entry : entries) {
            map.put(entry.getKey(), entry.getValue());
        }
        return Collections.unmodifiableMap(map);
    }

    public static <K, V> Map<K, V> map() {
        return new HashMap<K, V>();
    }

    /**
     * @return an <b>UNMODIFIABLE</b> Map&lt;K, V&gt;
     */
    public static <K, V> Map<K, V> unmodifiableMap(final Map<? extends K, ? extends V> m) {
        return (m == null) ? Collections.<K, V>emptyMap() : Collections.unmodifiableMap(m);
    }
}