Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { /** * Creates a Map out of an array with Strings. * * @param strings input strings, key-value alternating * @return a parameter map */ public static Map<String, String> map(final String... strings) { if (strings.length % 2 != 0) { throw new IllegalArgumentException("strings.length % 2 != 0"); } final Map<String, String> sMap = new HashMap<String, String>(); for (int i = 0; i < strings.length; i += 2) { sMap.put(strings[i], strings[i + 1]); } return sMap; } }