package test;
import java.util.HashMap;
public class YuGiOh
{
public static void main ( String[] args )
{
int a = 1, b = 2, c = 3;
int[] array = { a, b, c };
String strs = "a,b,c";
HashMapmap = new HashMap ();
for ( int i = 0; i < array.length; i++ )
{
map.put (strs.split ("\\,")[i], array[i]);
}
System.out.println (map);
}
}
把建立map放在循环内,你的做法肯定是在循环外建立map了。