+ 7

How to count occurrence of a given character in a String?

18th Nov 2016, 7:53 PM
David Kariuki
David Kariuki - avatar
2 Respostas
+ 2
String s = "..."; int counter = 0; for( int i=0; i<s.length(); i++ ) { if( s.charAt(i) == '
#x27; ) { counter++; } }
18th Nov 2016, 9:59 PM
nouhou mohamed
nouhou mohamed - avatar
0
مرحبا
19th Nov 2016, 7:22 PM
‫إبراهيم هوساوي‬‎
‫إبراهيم هوساوي‬‎ - avatar