在HashTabe中使用模糊查询

public void getvague(){
        Hashtable<String,String> hashi= new Hashtable<>();
        hashi.put("张三","张三");
        hashi.put("王张","王张");
        hashi.put("赵六","赵六");
        hashi.put("张飞","张飞");
        hashi.put("张三白","张三白");
        for (String has : hashi.keySet()) {//循环遍历数组
            if (has.contains("张")){//如果这里面有“张”这个关键字就输出
                System.out.println(hashi.get(has));
            }
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_42903710/article/details/86158576