lundi 6 décembre 2021

How Ignore the if case (i.e., consider “The” and “the” as the same word)

Sorry if this is an obvious problem.

I'm trying to read strings from users and store them in an array. but I want to Ignore the if case (i.e., consider “The” and “the” as the same word)

Thanks a lot for any help!

Scanner fileScanner = new Scanner(file);
        fileScanner.useDelimiter("[^A-Za-z0-9]");
        ArrayList<String> words = new ArrayList<String>();
        while (fileScanner.hasNext()) {
            String nextWord = fileScanner.next();
            if (!words.contains(nextWord) ) {
                words.add(nextWord);
            }
        }

Aucun commentaire:

Enregistrer un commentaire