Java tutorial
import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { List<String> stringList = Arrays.asList(args); System.out.println("before: " + stringList); for (int i = 0; i < stringList.size(); ++i) { stringList.set(i, stringList.get(i).replaceAll("\\s+", "")); } System.out.println("after : " + stringList); } }