我正在尝试将此模具的面映射返回到字母。使用整数值 1 到 6 来识别人脸,返回的地图按其键(人脸编号)排序。我的代码如下:
公共 SortedMap getValueMap() {
SortedMap<Integer, String> sm = new TreeMap<Integer, String>();
sm.put(new Integer(1), "A");
sm.put(new Integer(2), "A");
sm.put(new Integer(4), "E");
sm.put(new Integer(3), "E");
sm.put(new Integer(5), "G");
sm.put(new Integer(6), "N");
Set<Entry<Integer, String>> s = sm.entrySet();
Iterator<Entry<Integer, String>> i = s.iterator();
for (i=1; i.hasNext();) {
Map.Entry m = (Map.Entry) i.next();
int key = (Integer) m.getKey();
String sValue = (String) m.getValue();
}
return "Key :" + key + " value :" + sValue;
}