Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

count the number of occurrences of a character in a string java

String line = "apples.oranges.bananas";
int count = line.length() - line.replace(".", "").length();
System.out.println(count);//displays 2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #count #number #occurrences #character #string #java
ADD COMMENT
Topic
Name
4+4 =