Here you can find the source of toMap(String[] keys)
public static Map<String, Integer> toMap(String[] keys)
//package com.java2s; /*//from www . ja v a 2 s . c o m * Copyright (c) 2012 The ANTLR Project. All rights reserved. * Use of this file is governed by the BSD-3-Clause license that * can be found in the LICENSE.txt file in the project root. */ import java.util.HashMap; import java.util.Map; public class Main { /** Convert array of strings to string→index map. Useful for * converting rulenames to name→ruleindex map. */ public static Map<String, Integer> toMap(String[] keys) { Map<String, Integer> m = new HashMap<String, Integer>(); for (int i = 0; i < keys.length; i++) { m.put(keys[i], i); } return m; } }