Question: What is wrong with the following code, which attempts to count the number occurrences of the letter 'e' in a String , case-insensitively? int count

What is wrong with the following code, which attempts to count the number occurrences of the letter 'e' in a String , case-insensitively?

int count = 0; for (int i = 0; i < s.length (); i++) { if (s.charAt (i).toLowerCase () 'e') { %3D%3D count++; }

int count = 0; for (int i = 0; i < s.length (); i++) { if (s.charAt (i).toLowerCase () 'e') { %3D%3D count++; }

Step by Step Solution

3.50 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The toLowerCase method cannot be called on a char value which is what the cha... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!