Java tutorial
//package com.java2s; import java.util.TreeMap; public class Main { public static <T> TreeMap<String, T> arraryToTreeMap(T[] itemsArray) { TreeMap<String, T> map = new TreeMap<String, T>(); T[] arrayOfObject = itemsArray; int j = itemsArray.length; for (int i = 0; i < j; i++) { T s = arrayOfObject[i]; map.put(s.toString(), s); } return map; } }