Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #count #replace #string #java
ADD COMMENT
Topic
Name
4+4 =