(String string : strings) { result += string; } return result; } public String concatenateStrings(String[] strings) { StringBuilder result = new StringBuilder(); for (String string : strings) { result.append(string); } return result.toString(); } Don't concatenate Strings in loop. Use StringBuilder instead. Strings are immutable so each time you concatenate a String, a new String is created. This is a waste of memory and CPU.