hey thnx buddy that is really tricky.
:D
:D
Originally posted by JosAH
int count = 0;
int i = 0;
while (true) {
i = yourString.indexOf(i);
if (i == -1)
break;
i++;
count++;
}
return count;
int count = 0;
int i = 0;
while (true) {
i = yourString.indexOf(i);
if (i == -1)
break;
i++;
count++;
}
return count;
1: int count = 0;
2: int i = 0;
3: while (true) {
4: i = yourString.indexOf(yourChar, i);
5: if (i == -1)
6: break;
7: i++;
8: count++;
9: }
while ((i= yourString.indexOf(yourChar, i)) != -1) ...
for( ; (i= yourString.indexOf(yourChar, i)) != -1; i++, count++);
for(int i= 0 ; (i= yourString.indexOf(yourChar, i)) != -1; i++, count++);
/**
* @param s the string to look for
* @param t the text to look through for 's'
* @return the number of times 's' is in 't'
*/
public static int count(String s, String t) {
return (t.length()-t.replaceAll(s, "").length())/s.length();
}
/**
* @param s the string to look for
* @param t the text to look through for 's'
* @return the number of times 's' is in 't'
*/
public static int count(String s, String t) {
return (t.length()-t.replaceAll(s, "").length())/s.length();
}
Comment