String someString = "elephant";
long count = someString.chars().filter(ch -> ch == 'e').count();
assertEquals(2, count);
long count2 = someString.codePoints().filter(ch -> ch == 'e').count();
assertEquals(2, count2);
String line = "apples.oranges.bananas";
int count = line.length() - line.replace(".", "").length();
System.out.println(count);//displays 2