I have a String, which contains a lot of commas.
I want to count all the commas in the String but I don't know how.
I'm using (split(",")-1)
But the problem is that if I input a String like this: One,Two,Three,Four,,,
Then it returns only 3 while I want it to be 6.
I think it is because split(",")
returns a String[] that does not include null or empty values.
Is there any way to solve this problem?