What? I'm confused, you already have them in a single string with spaces between them. remove String string = Integer.toString(i); and just return string in the method.