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");
}
}
{
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");
}
}
0 comments:
Post a Comment