change array to string code example

Example 1: jquery convert a string to an array

var numbersString = "1,2,3,4,5,6";
var numbersArray = numbersString.split(',');

Example 2: js array to string

var myArray = ['no','u'];
var myString = myArray.toString();

Example 3: javascript convert in a string the items of an array

const arr = [1, 2, 'a', '1a'];
const str = arr.toString();
console.log(str); //> "1,2,a,1a"

Example 4: java string array to one string

public class ArrayOfStrings {
   public static void main(String args[]) {
      String stringArray[] = {"Hello ", " how", " are", " you", " welcome", " to", " Tutorialspoint"};
      StringBuffer sb = new StringBuffer();
      for(int i = 0; i < stringArray.length; i++) {
         sb.append(stringArray[i]);
      }
      String str = sb.toString();
      System.out.println(str);
   }
}

Example 5: array to string java

char[] charArray = new char[] {'b','u','z','z'};

String answer = new String(charArray);

Example 6: turn array into string

const elements = ['Fire', 'Air', 'Water'];

console.log(elements.join());
// expected output: "Fire,Air,Water"

console.log(elements.join(''));
// expected output: "FireAirWater"

console.log(elements.join('-'));
// expected output: "Fire-Air-Water"