用世神length()方法、charAt方法纯银结合for循做返宴环就行了,
package com.golden.test;
public class TestString {
public static void main(String[] args) {
String str = "你叫神马?我叫Tesson.";
for (int i = 0; i < str.length(); i++) {
char item = str.charAt(i);
System.out.println(item);
}
}
}
import java.util.*;
public class Test {
public Map
Map
for (int i = 0; i <缺姿 string.length(); i++) {
char c = string.charAt(i);
if(null == map.get(c))map.put(c, 1);
else {
int length = map.get(c)+1;
map.put(c, length);
}
}
return map;
}
public static void main(String[] args) {
Test test = new Test();
Map
for (Entry
System.out.println(entry.getKey()+":"+entry.getValue());
}
}
}