集册 Java实例教程 搜索地图忽略大小写

搜索地图忽略大小写

欢马劈雪     最近更新时间:2020-01-02 10:19:05

575
搜索地图忽略大小写
//from n o w    j a v a  . c o m

//package com.nowjava;


import java.util.Iterator;

import java.util.Map;


public class Main {

    public static String searchMapIgnoreCase(Map hm, String searchFor) {


        Iterator i = hm.entrySet().iterator();

        String newName = null;


        while (i.hasNext()) {


            Map.Entry entry = (Map.Entry) i.next();

            String key = (String) entry.getKey();

            String value = (String) entry.getValue();
/* from n o w  j a v a  . c o m*/

            if (key.equalsIgnoreCase(searchFor))

                newName = value;


            
展开阅读全文