문제

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

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top