ArrayList contains case sensitivity

前端 未结 19 1791
故里飘歌
故里飘歌 2020-11-27 17:14

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

19条回答
  •  借酒劲吻你
    2020-11-27 18:08

    Assuming you have an ArrayList

    About the only way I can think of to do this would be to create a very light wrapper class around a String and override equals and hashcode to ignore case, leveraging equalsIgnoreCase() where possible. Then you would have an ArrayList. It's kinda an ugly idea though.

提交回复
热议问题