Answers for "java replaceall count"

0

how to count an replace string in java

public static void main(String[] args) throws Exception {
        String word = "abcdefg";
        System.out.println(word.length());
        System.out.println(word.replace("a", "").length());
        int a_counter = word.length() - word.replace("a", "").length();
        System.out.println(a_counter);
}
Posted by: Guest on June-07-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language