I have big string array and on every index I have a letter. I need to make a recall from this array and compose all this letters to one word/string. How would I do that in java?
String[] letters;
int lettersToRecall =16;
String word;
for(int i=0; i<lettersToRecall; i++){
//accumm letters into String Word..
}
This most straightforward method is to add all strings together:
This method (simply adding
Stringobjects) wastes lots ofStringinstances as each addition result in a new instance.So, if you are concerned with resource usage you could use
StringBuilderinstead:For more information check when to use StringBuilder in java