展开全部
1.字符串e69da5e887aa3231313335323631343130323136353331333337613834转字符
for(int i = 0; i
str.charAt(i);
2+3:不想循环的话 可以用一个List装字符,每次装之前调用if(List.contains(..))
package com.xuz.csdn.worldcup.day22;
import java.util.HashMap;
import java.util.Map;
public class HelloWorldCountTest {
public static void main(String[] args) {
String hello = "helloworld!";
Map map = new HashMap();
char[] ch = hello.toCharArray();
for (char c : ch) {
Integer i = map.get(c);
if (i == null) {
map.put(c, 1);
} else {
map.put(c, i.intValue() + 1);
}
}
System.out.println(map);
}
}
或者static Map sortMap(Map map) {
List list = new LinkedList(map.entrySet());