Contains method case-insensitive without major code changes?

后端 未结 1 595
误落风尘
误落风尘 2021-01-27 22:30

Is there a way to ignore the case for the contains() method but at the same time leave the code snippet more or less the same?

/**
 * This method returns a list          


        
1条回答
  •  礼貌的吻别
    2021-01-27 23:09

    Make both strings lowercase(or uppercase)

    public ArrayList wordsContaining(String text)
    {
        int index = 0; 
        text = text.toLowerCase();
        ArrayList wordsContaining = new ArrayList();      
        while(index

    0 讨论(0)
提交回复
热议问题