JAVA:如何搜索地图? [英] JAVA: How to search a map?
本文介绍了JAVA:如何搜索地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Map,其键的字符串为String,其值的集合(包含整数)
I have a Map that has Strings for its keys and sets (that contain integers) for its values
说我的钥匙看起来像是苹果",香蕉",橙色"等.
Say my keys look like this "apple", "banana", "orange", etc.
用户输入文本,然后将其另存为String变量.如何在地图上搜索相同的密钥? 因此,如果用户键入"apple",我该如何将该String赋予方法,并让该方法在我的地图中搜索"apple"键并返回与之关联的整数集(值)?
The user enters text and I save it as a String variable. How do I search my map for an identical key? So if the user types in "apple" how do I give that String to a method and have the method search my map for the "apple" key and return the set of Integers associated with it (values)?
谢谢
推荐答案
查看全文