Java tutorial
//package com.java2s; import java.util.*; public class Main { public static Map<String, String> toMap(String... arr) { Map<String, String> map = new HashMap<String, String>(); if (arr.length == 0 || arr.length % 2 != 0) { throw new IllegalArgumentException(Arrays.toString(arr) + " should have an even number of arguments"); } for (int i = 0; i < arr.length; i += 2) { map.put(arr[i], arr[i + 1]); } return map; } }