import java.util.Arrays; public class NameManipulator { public static void main(String[] args) { String[] names = {"Philip Fry", "Hubert Farnsworth", "Bender Bending Rodriguez", "John Zoidberg"}; for (int i = 0; i < names.length; i++) { /* x = change(x) */ names[i] = shorten(names[i]); } System.out.println(Arrays.toString(names)); } /** pre: name is a string containing a name * with spaces. * post: removes all spaces from the name */ public static String shorten(String name) { /* We must *return* the result, because * it's a new String. */ return name.replace(" ", ""); } }