In Java 8, you should use something like:
List<String> trimmedStrings =
originalStrings.stream().map(String::trim).collect(Collectors.toList());
also it is possible to use unary String::trim
operator for elements of the initial list (untrimmed String
instances will be overwritten) by calling this method:
originalStrings.replaceAll(String::trim);