假设我们有一个如下所示的HashMap:
{tones=
[
{score=0.534486, tone_id=joy, tone_name=Joy},
{score=0.619262, tone_id=sadness, tone_name=Sadness},
{score=0.829266, tone_id=analytical, tone_name=Analytical}
]
}
并且我们仅从中提取“分数”值和“ tone_name”值,我们该怎么做?
答案 0 :(得分:1)
尝试一下:
Iterator it = tones.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
if("score".equalsIgnoreCase(pair.getValue()) || "tone_name".equalsIgnoreCase(pair.getValue())){
iter.remove();
}
}