为什么会这样运行:
static TreeMap<String, int[]> configs = new TreeMap<String, int[]>();
int[] upperarms_body = {2,3,4,6};
int[] left_arm = {1,2};
int[] right_arm = {6,7};
int[] right_side = {5,6,7};
int[] head_sternum = {3,4};
configs.put("upperarms_body", upperarms_body);
configs.put("left_arm", left_arm);
configs.put("right_arm", right_arm);
configs.put("right_side", right_side);
configs.put("head_sternum", head_sternum);
// create a config counter
String[] combi = new String[configs.keySet().size()];
Set<String> s = configs.keySet();
int g = 0;
for(Object str : s){
combi[g] = (String) str;
}
这不是:
static TreeMap<String, int[]> configs = new TreeMap<String, int[]>();
int[] upperarms_body = {2,3,4,6};
int[] left_arm = {1,2};
int[] right_arm = {6,7};
int[] right_side = {5,6,7};
int[] head_sternum = {3,4};
configs.put("upperarms_body", upperarms_body);
configs.put("left_arm", left_arm);
configs.put("right_arm", right_arm);
configs.put("right_side", right_side);
configs.put("head_sternum", head_sternum);
//get an array of thekeys which are strings
String[] combi = (String[]) configs.keySet().toArray();