Java Map to String toStringMap(String... pairs)

Here you can find the source of toStringMap(String... pairs)

Description

to String Map

License

Apache License

Declaration

public static Map<String, String> toStringMap(String... pairs) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static Map<String, String> toStringMap(String... pairs) {
        Map<String, String> parameters = new HashMap<String, String>();
        if (pairs.length > 0) {
            if (pairs.length % 2 != 0) {
                throw new IllegalArgumentException("pairs must be even.");
            }/*  w ww .  j ava  2  s.  c o m*/
            for (int i = 0; i < pairs.length; i = i + 2) {
                parameters.put(pairs[i], pairs[i + 1]);
            }
        }
        return parameters;
    }
}

Related

  1. toStringMap( Map enumMap)
  2. toStringMap(Map map)
  3. toStringMap(Map src)
  4. toStringMap(Properties properties)
  5. toStringMap(String... pairs)