有没有一个很好的方法来拥有一个Map< String,?>得到和放弃无视的情况? [英] Is there a good way to have a Map<String, ?> get and put ignoring case?

查看:149
本文介绍了有没有一个很好的方法来拥有一个Map< String,?>得到和放弃无视的情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

h2_lin>解决方案

TreeMap扩展Map并支持自定义比较器。



String提供了一个默认的不区分大小写的比较器。



所以:

  final Map< String,...> map = new TreeMap<(String.CASE_INSENSITIVE_ORDER); 

比较器不考虑区域设置。在JavaDoc中了解更多信息。


Is there a good way to have a Map<String, ?> get and put ignoring case?

解决方案

TreeMap extends Map and supports custom comparators.

String provides a default case insensitive comparator.

So:

final Map<String, ...> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

The comparator does not take locale into account. Read more about it in its JavaDoc.

这篇关于有没有一个很好的方法来拥有一个Map&lt; String,?&gt;得到和放弃无视的情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆