This week's book giveaway is in the Programmer Certification forum. We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
You may be confusing String.trim() and Iterator.remove().
You would want access to the iterator to remove items from the list. Invoking trim on a string will return a new string instance that has been trimmed (white space removed from the front and back).
To get access to the iterator, you use the old form (pre Java 5) of the for loop.
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Whenever you use the new for loop, you lose the iterator or array indexes. It's a price you pay for the shorter code.
So if you need the iterator to remove items, the array index (e.g. to copy array items) or a list iterator (because of the add and set methods), there is no other option but to use the old for loop.