你上面的程序没有问题啊
我试都可以
import java.util.*;
class TestFinally
{
    public static void main(String[] args) 
    {
    HashMap h=new HashMap();

String[] name=new String[]
{
"tr_code","answer"
};

h.put(name[0],"5020001");
h.put(name[1],"1000232");
System.out.println(h);
    }
}