Java program to count the occurrence of any character in given String.
for (int i = 0; i < len; i++) {
x = Character.toLowerCase(s.charAt(i));
if (x == a)
c = c + 1;
}
System.out.println("Frequency of the letter " + a + " in the sentence " + s + " is " + c);
x = Character.toLowerCase(s.charAt(i));
if (x == a)
c = c + 1;
}
System.out.println("Frequency of the letter " + a + " in the sentence " + s + " is " + c);
Comments
Post a Comment