ArrayList contains case sensitivity

前端 未结 19 1769
故里飘歌
故里飘歌 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:10

    In Java8, using anyMatch

    List list = Arrays.asList("XYZ", "ABC");
    String matchingText = "xYz";
    
    boolean isMatched = list.stream().anyMatch(matchingText::equalsIgnoreCase);
    

提交回复
热议问题