ArrayList包含大小写 [英] ArrayList contains case sensitivity

查看:845
本文介绍了ArrayList包含大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的包含属于ArrayList类用于制作搜索方法。有没有一种方法,使这个搜索情况下在java中不区分大小写?我发现,在C#,可以使用OrdinalIgnoreCase。是否有一个相当于Java,或另一种方式来做到这一点?
谢谢你。

I am currently using the contains method belonging to the ArrayList class for making a search. Is there a way to make this search case insensitive in java? I found that in C# it is possible to use OrdinalIgnoreCase. Is there a java equivalent, or another way to do this? Thanks.

推荐答案

您可以准确地使用这个就像你使用任何其他的ArrayList。你可以通过这个列表输出到其他code和外部code将不必了解所有字符串包装类。

You can use this exactly like you'd use any other ArrayList. You can pass this List out to other code, and external code won't have to understand any string wrapper classes.

public class CustomStringList3 extends ArrayList<String> {
    @Override
    public boolean contains(Object o) {
        String paramStr = (String)o;
        for (String s : this) {
            if (paramStr.equalsIgnoreCase(s)) return true;
        }
        return false;
    }
}

这篇关于ArrayList包含大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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