Answers for "count how many times a character appears in a string java"

0

check how many times a character appears in a string java

str.chars().filter(num -> num == '$').count()
Posted by: Guest on January-31-2021
0

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
Posted by: Guest on May-31-2021

Code answers related to "count how many times a character appears in a string java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language