-
Counting characters in Java
There are many ways for counting the number of characters in a String. Below a simple/naive approach:
-
Counting words in Java
This is a simple way to count words in a string in Java. StringTokenizer automatically takes care of whitespace for us, like tabs and carriage returns. In some cases like in “he-man”, we’d want “he” and “man” to be different words, but since there’s no whitespace between them, the defaults fail us. Fortunately, we can […]