字符串转换成map型
package com.com.collections;
import java.util.HashMap;
import java.util.Map;
public class Homeworks {
public static void main(String[] args) {
String str = "k:1,k1:2,k2:3";
//map形式
//线切割
String[] strs = str.split(",");
//对数组循环遍历
Map<String,Integer> map = new HashMap<>();
for (String s : strs){
String[] ss = s.split(":");
map.put(ss[0],Integer.parseInt(ss[1]));
}
System.out.println(map);
}
}