java string count
String line = "Your string here";
String stringToCount = "?";
int count = line.length() - line.replace(stringToCount, "").length();
java string count
String line = "Your string here";
String stringToCount = "?";
int count = line.length() - line.replace(stringToCount, "").length();
counting the number of characters in a string java
public static void main(String[] args) {
int wordCount = 0;
String word = "hill";
for (char letter = 'a'; letter <= 'z'; letter++) {
for (int i = 0; i < word.length(); i++) {
if (word.charAt(i) == letter) {
wordCount++;
}
}
if (wordCount > 0) {
System.out.println(letter + "=" + wordCount);
wordCount = 0;
}
}
}
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