public static void main(String[] args) {
String s = "{ 1:33 }, { 2:30 }, { 3:15 }, { 4:23 }, { 9:17 }, { U:2 }, { V:22 }, { W:1 }, { X:35 }, { Y:6 }, { Z:19 }";
String[] arr = s.split(", ");
Map<String, Integer> map = new HashMap<String, Integer>();
for (String str : arr) {
str = str.replace("{", "").replace("}", "");
String[] splited = str.split(":");
map.put(splited[0], Integer.parseInt(splited[1].trim()));
}
System.out.println(map);
}
输出:
{ 9=17, Z=19, Y=6, X=35, 1=33, 3=15, 2=30, W=1, V=22, 4=23, U=2}