Java Map Create createMap(String[] list1, String[] list2)

Here you can find the source of createMap(String[] list1, String[] list2)

Description

Create a map from the two list of strings.

License

Open Source License

Parameter

Parameter Description
list1 a parameter
list2 a parameter

Return

Map

Declaration

public static Map<String, String> createMap(String[] list1, String[] list2) 

Method Source Code

//package com.java2s;
/*-/* w ww . j a  v a  2  s  . com*/
 * Copyright ? 2009 Diamond Light Source Ltd.
 *
 * This file is part of GDA.
 *
 * GDA is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License version 3 as published by the Free
 * Software Foundation.
 *
 * GDA is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along
 * with GDA. If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**
     * Create a map from the two list of strings.
     * @param list1
     * @param list2
     * @return Map
     */
    public static Map<String, String> createMap(String[] list1, String[] list2) {
        final Map<String, String> ret = new HashMap<String, String>(list1.length);
        for (int i = 0; i < list1.length; i++) {
            ret.put(list1[i].trim(), list2[i].trim());
        }
        return ret;
    }
}

Related

  1. createMap(Object... objects)
  2. createMap(Object... objects)
  3. createMap(Object[] keysValues)
  4. createMap(String entries)
  5. createMap(String key, Object value)
  6. createMap(String[] mappings, String sep)
  7. createMap(T... _args)
  8. createMap(U... items)
  9. createMap_pollutantHourly()