Here you can find the source of arrayToMap(int[] array)
public static Map<Integer, Integer> arrayToMap(int[] array)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { public static Map<Integer, Integer> arrayToMap(int[] array) { Map<Integer, Integer> ret = new HashMap<Integer, Integer>(); for (int i = 0; i < array.length; i++) ret.put(i + 1, array[i]);/*from w w w. ja va2s . co m*/ return ret; } public static <T> Map<Integer, T> arrayToMap(T[] array) { Map<Integer, T> ret = new HashMap<Integer, T>(); for (int i = 0; i < array.length; i++) ret.put(i + 1, array[i]); return ret; } }