jeudi 1 juillet 2021

How to put together different if statements and for loops in java?

I am a beginner in programming and I need some help! I have these for-loops and if statements, how could I shorten the code?

       `for (int i = 0; i < Sentence.length(); i++) {
            if (Sentence.charAt(i) != ' ') {                                                                                          
                totalNumberOfCharaters++;
            }
        }

        for (int i = 0; i < Sentence.length(); i++) {                                                                                 
            if (Sentence.charAt(i) == symbolInput.charAt(i) ) {
                numberOfSymbols++;
            }
        }`

Aucun commentaire:

Enregistrer un commentaire