如何将<String>设置值添加到 for 循环中的列表?



我想迭代accountset List<AccountTO>的值并设置为 AccountID

实际上,在accountset中,我正在获取值:100,101,102我想将这些值添加到List<AccounTO>并将它们设置为AccountID并将其传递给服务调用。有没有我可以去的,或者任何其他程序。

for(String s :group.getAccounts().keySet())
{
    System.out.println("===="+s.lastIndexOf("-"));
    System.out.println("sub"+s.substring(0,s.lastIndexOf("-")));
    accountSet.add(s.substring(0, s.lastIndexOf("-")));
}
如果我

正确理解这个问题,它应该相当简单:

List<AssetAllocationTO> someList = new ArrayList<AssetAllocationTO>();
for (String string : group.getAccounts().keySet()){
            AssetAllocationTO al = new AssetAllocationTO();
            al.setAccountID(string);
            someList.add(al);
}

最新更新