HashSet<String> outScopeActiveRegionCodeSet=new HashSet<String>();
for (String regionCode : outScopeActiveRegionCodeSet) {
//code required
}
Here i need to create new TransactionLOgDTO objects dynamically insed the loop like below.If there are 3 regioncodes in hashset i need 3 TransactionLOgDTO objects with regionCode appended to name of new object.
TransactionLOgDTO regionCode1DTO=new TransactionLOgDTO();
}
I need something like this to be done………………………
for (String regionCode : outScopeActiveRegionCodeSet) { TransactionLOgDTO "regionCode"+DTO=new TransactionLOgDTO(); }
I would recommend using an
ArrayListinstead of putting the index in the variable name:or, since you aren’t using the
regionCodeString:Then you can access them using:
[EDIT]
If you want to connect the
regionCodeto theTransactionLogDTOI would recommend aMap instead:which are retrieved like: