Finding Repetition of a character in a string
Oct 5, 2013
Make sure to subscribe to our newsletter and be the first to know the news.
Oct 5, 2013
Make sure to subscribe to our newsletter and be the first to know the news.
public class CharacterFinder
{
public static void main(String[] args)
{
int mCounter=0;
String name="Tommy";
for (int i=0;i<name.length() ;i++ )
{
char c=name.charAt(i);
if (Character.toString(c).equalsIgnoreCase("m"))
{
mCounter++;
}
}
System.out.println("Word m is repeated "+mCounter+" times in the given string");
}
}