//其实挺简单的,不过我还是忘记了values 和spilt分割小数点需要转义字符\\,谢谢
[AppleScript] 纯文本查看 复制代码 public static void main(String[] args) {
String string = "1.2,3.4,5.6,7.8,5.56,44.55";
String [] num = string.split(",");
Map<Object , Object> map = new LinkedHashMap<>();
for (int i = 0; i < num.length; i++) {
String [] arr = num[i].split("\\.");
map.put(arr[0], arr[1]);
}
Set <Object> set = map.keySet();
for (Object object : set) {
System.out.println(object);
}
Collection<Object> collection = map.values();
for (Object object : collection) {
System.out.println(object);
}
}
}
|