Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个像String[] selectedJobs = {"job,1","job,2", "Job2,1", "job3,1"};
String[] selectedJobs = {"job,1","job,2", "Job2,1", "job3,1"};
我想提取信息,例如
Job -> 1,2 Job2 -> 1 Job3 -> 1 Map<String, List<String>> jobs = new HashMap<String, List<String>>();
我想将每个作业与相应的整数列表存储在 map 中。
这个怎么做 ?
你试过什么?该算法不应该很棘手:遍历您的数组,为每个字符串拆分“,”,并将其放入您描述的 HashMap 中。