public class Test
{
public static void main(String[] args) {
String test="Hi I am here am am too good am very a m";
String find="am";
int count=0;
String a[]=test.split(" ");
for (int j = 0; j < a.length; j++) {
if(a[j].equals(find))
{
count++;
}
}
System.out.println(count);
}
}
{
public static void main(String[] args) {
String test="Hi I am here am am too good am very a m";
String find="am";
int count=0;
String a[]=test.split(" ");
for (int j = 0; j < a.length; j++) {
if(a[j].equals(find))
{
count++;
}
}
System.out.println(count);
}
}
Post a Comment