提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
检查HashMap是否存在特定值
import java.util.HashMap; /*来自 nowjava - 时 代 Java*/ public class Main { public static void main(String[] args) { HashMap hMap = new HashMap(); hMap.put("1","One"); hMap.put("2","Two"); hMap.put("3","Three"); boolean blnExists = hMap.containsValue("Two"); System.out.println("Two exists in HashMap ? : " + blnExists); } }