问题描述
我正在为需要学习最常用单词的年轻学生创建一个教育游戏.我随机选择列表中的三个单词,将它们显示在屏幕上,播放三个单词之一的录音,然后学生必须选择已经发音的单词.我记录了他们每个单词猜了多少次.通过这种方式,我可以为何时应该向学生介绍新单词设置一个标准.When three of the words are picked I'll like to pronounce the word that the student has had least exposure to.
I'm creating an educational game for young students who needs to learn the most common words. On random I pick three words of the list, show them on the screen, play an audio recording of one of the three words and then the student has to pick the word that has been pronounced. I keep track of how many times they have guessed each word. In that way I can set up a criteria for when new words should be introduced to the student. When three of the words are picked I'll like to pronounce the word that the student has had least exposure to.
我有一个名为 words 的 HashMap,其中包含单词,以及学生猜出单词的次数的整数值.
I have a HashMap called words, which contains the words, and a integer value of how many times the student guessed the word.
HashMap<String,Integer> words
它包含 10 - 120 个键/词.我想创建一个方法,它将三个哈希映射键作为参数,它可以返回具有最低要求键值的字符串/键.
It contains between 10 - 120 keys/words. I'll like to create a method, which takes three of the hash map keys as parameters, that can return the String/key having the lowest value of the keys asked for.
我很难让它按预期工作,如果能提供任何帮助,我将不胜感激.
I have had trouple getting this to work as intended and I'd appreciate any help.
推荐答案
这个怎么样?
private String getMinKey(Map<String, Integer> map, String... keys) {
String minKey = null;
int minValue = Integer.MAX_VALUE;
for(String key : keys) {
int value = map.get(key);
if(value < minValue) {
minValue = value;
minKey = key;
}
}
return minKey;
}
这篇关于找到保存最小整数值的 HashMap 的键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)