level 11
就是在一串字符里找一个字符出现的次数? 我只会用数组。其他还没想出来。
2014年09月25日 17点09分
1
level 3
public class Test {
public static void main(String[] args) {
String s = "asdasdsasdsadasssa";
int sum = 0;
for (int i = 0; i <= s.length() - 1; i++) {
char c = s.charAt(i);
if ("s".equals(c + "")) {
sum++;
}
}
System.out.println("s出现"+sum+"次");
}
}
2014年09月26日 01点09分
2
level 8
String str = "adfasfasdfasdf";
char c = *s*;
int count = str.length() - str.replace(String.valueOf(c)).length();
2014年09月26日 01点09分
3
repace(String.valueOf(c), "")……
2014年09月26日 01点09分
level 13
其实啊,楼上写的用各种类库里的方法时间复杂度都差不多。。。
2014年09月26日 02点09分
5
level 6
String在构建的时候,实际上是封装了一个char[].
2014年09月26日 02点09分
7
level 8
直接用这个字符来分割,得到分割后的数组length
2014年09月26日 05点09分
9