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.
我想在方法调用中从集合转换为列表。现在这就是我所做的:
List<Integer> lrsIdList = new ArrayList<Integer>(); lrsIdList.addAll(repaymentMap.keySet()); getObjects(lrsIdList)
我该怎么做呢?
假设您的repaymentMap.keySet()退货Set<Integer>
repaymentMap.keySet()
Set<Integer>
getObjects(new ArrayList<Integer>(repaymentMap.keySet()));
您可以通过将 Set 实例传递给 List 实现类(如 ArrayList)的构造函数来将 Set 转换为 List。
List<String> list = new ArrayList<String>(hashset);