I need to convert a string vector in a simple string. I do not know how to proceed.
I tried various solutions such as
for(int i=1; i < easy.length; i++){
easyPuzzle = easy[i].toString();
}
System.out.println(" " + easyPuzzle);
but this solution prints only the ith element and not the entire string vector.
You keep reassign a new value to
easyPuzzlewhen you really want to concatenate:If
easy.lengthis large, it might make sense to use a StringBuilder which is more efficient at concatenating than String:Also by starting your for loop at
i=1you exclude the first item. Not sure if it is on purpose or not. If not, start ati = 0.Alternatively, to save the pain of writing the loop yourself, you can use @Manoj’s answer which replaces your code by one line.