I would like to combine all the Strings in an array to one String just by loops. How do I do it?
public class HelloWorld {
public static void main(String[] args) {
String [] x = {"ab", "bc", "cd"};
String z = concatination(x, 3);
System.out.println(z);
}
public static String concatination(String [] array, int i ){
for(int j = 0; j<array.length-1; j++){
return (array[j]);
}
return " ";
}
}
output:
java unreachable statement
Expected output:
abbccd
Thank you