Here you can find the source of map(String... strings)
Parameter | Description |
---|---|
strings | input strings, key-value alternating |
public static Map<String, String> map(String... strings)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { /**//from w w w . j av a 2 s . c o m * 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(String... strings) { if (strings.length % 2 != 0) throw new IllegalArgumentException("strings.length % 2 != 0"); Map<String, String> mp = new HashMap<String, String>(); for (int i = 0; i < strings.length; i += 2) { mp.put(strings[i], strings[i + 1]); } return mp; } }