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 中。
我在 Ruby on Rails 中构建了一个小型 Twitter 克隆。它有一个用户模型、一个微博模型和一个关系模型。关系模型存储关注的用户 ID 和相应的关注用户 ID。我正在尝试添加一个新按钮,使当前用户在他们的微帖子中使用匹配参数关注所有其他用户。我已将该参数添加到 micropost 模型中。问题是,当我在 micropost 模型中查询数据库以查