我想将另一个字符串作为哈希映射的 lastEntry 的键。
检查 lastEntry 的值并对其进行更改后,我无法使用 setKey 或其他函数来更改我想更改 lastEntry 的密钥。
EditText name; // put that as the key
Map<String,Integer> Names = new HashMap<String,Integer>(10);
// .
// .
// .
name = (EditText) findViewById(R.id.namep);
我的函数检查 lastEntry 的值并更改它:
boolean flagScore = false;
Entry<String, Integer> lastEntry = Names.lastEntry();
if(lastEntry.getValue() < score){
lastEntry.setValue(score);
flagScore = true;
}
if(flagScore){
// put name.getText().toString as key
}