how to test how many of one character is in a string java
int count = string.length() - string.replaceAll("g","").length()
how to test how many of one character is in a string java
int count = string.length() - string.replaceAll("g","").length()
check how many of a word is in a string
function countOccurences(str,word)
{
// split the string by spaces in a
String a[] = str.split(",");
// search for pattern in a
int count = 0;
for (int i = 0; i < a.length; i++)
{
// if match found increase count
if (word.equals(a[i]))
count++;
}
return count;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us