2012-05-08 102 views
-5

我想迭代accountsetList<AccountTO>的值並將其設置爲AccountID如何在for循環中將Set <String>值添加到列表中?

其實在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("-"))); 
} 
+5

問題結構真的很差,解決方案可能是簡單的,如果你會把精力在寫你的問題好一點 – ant

+0

@prashanth請重新格式化你的問題,並更好地解釋它,我不明白什麼是輸入和代碼應該做什麼 – dbf

+0

設置 accountSet = new HashSet ();我需要將帳戶集添加到列表

回答

1

如果我理解正確的問題應該是相當簡單:

List<AssetAllocationTO> someList = new ArrayList<AssetAllocationTO>(); 

for (String string : group.getAccounts().keySet()){ 
      AssetAllocationTO al = new AssetAllocationTO(); 
      al.setAccountID(string); 
      someList.add(al); 
} 
+0

這些值是在記帳集中,不需要它? –

相關問題