Program to count occurrence of a given character in a string uisng java code example
Example: How do you count characters in a string array in Java?
package practical5;
import java.util.Arrays;
public class Part1_9 {
public static void main(String[] args) {
String quoteArray[] = { "\"Continuous", "effort", "not", "strength",
"nor", "intelligence", "is", "the", "key", "to", "unlocking",
"our", "potential.\"\n" };
for (int counter = 0; counter < quoteArray.length; counter++) {
System.out.print(quoteArray[counter] + " ");
}
for (String element : quoteArray) {
System.out.print(element + " ");
}
System.out.println();
System.out.println("Number of words in array: " + quoteArray.length);
**
for (int counter = 0; counter < quoteArray.length; counter++) {
String letters = new String(quoteArray[counter]);
}
}
}