Modifying each item of a List in java
问题 I'm just starting to work with lists in java. I'm wondering what the recommended method to modify each element of a list would be? I've been able to get it done with both the following methods, but they both seem fairly unelegant. Is there any better way to get this done in java? And is any of the below methods recommended over the other, or are both on the same level? //Modifying with foreach for (String each : list) { list.set(list.indexOf(each), each+ " blah"); } //Modifying with for for