Frage

I need to know the count of a character in a String Variable. It's possible in PHP with substrcount.

Now, what's Equivalent substrcount in android(java)?

Edited :

For example count of (:) in

  String a="abc:def:gh:test"

---------> count of (:) = 3

War es hilfreich?

Lösung

Yes StringTokenizer is there, You can try following way,

String str = "abc:def:gh:test";
StringTokenizer st = new StringTokenizer(str,":");
int count = st.countTokens() - 1;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top