Java HashMap to String toStringArray(HashMap syms)

Here you can find the source of toStringArray(HashMap syms)

Description

Convert a HashMap to string array

License

Open Source License

Parameter

Parameter Description
syms the input HashMap

Return

the strings array

Declaration

public static String[] toStringArray(HashMap<String, Integer> syms) 

Method Source Code

//package com.java2s;
/**/*from   www .j  a  v  a2  s .  co m*/
 * 
 * Copyright 1999-2012 Carnegie Mellon University.  
 * Portions Copyright 2002 Sun Microsystems, Inc.  
 * Portions Copyright 2002 Mitsubishi Electric Research Laboratories.
 * All Rights Reserved.  Use is subject to license terms.
 * 
 * See the file "license.terms" for information on usage and
 * redistribution of this file, and for a DISCLAIMER OF ALL 
 * WARRANTIES.
 *
 */

import java.util.HashMap;

public class Main {
    /**
     * Convert a HashMap to string array
     * 
     * @param syms the input HashMap
     * @return the strings array
     */
    public static String[] toStringArray(HashMap<String, Integer> syms) {
        String[] res = new String[syms.size()];
        for (String sym : syms.keySet()) {
            res[syms.get(sym)] = sym;
        }
        return res;
    }
}

Related

  1. toString(HashMap map)
  2. toStringLong(HashMap map)