Check out example codes for "array to string". It will help you in understanding the concepts better.

Code Example 1

// Defining an array with most datatypes ( objects have to be converted to string with JSON.stringify(obj) )
var myArray = ['String',"String",1,2.5, false, NaN, undefined]; 
// Convert the array into a string using the JS function toString();
var myString = myArray.toString();
// Logging it on the console
console.log(myString) // "String,String,1,2.5,false,NaN," (undefined values cannot be converted to strings)

Code Example 2

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

Code Example 3

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"

Code Example 4

arr.join()
arr.join(séparateur)

let monTableau = ['un', 'deux','trois', 'quatre'] ;
console.log(monTableau.join('/ ')) ;

/////////////////or//////////////////////

let monTableau2D = [
     ['Mark' , 'jeff' , 'Bill'] , 
     ['Zuckerberg' , 'Bezos' , 'Gates']
 ] ;
 
 console.log(monTableau2D[0].join(', '))
            // or 
 console.log(monTableau2D.join('/ '))

Code Example 5

int[] numbers = new int[]{1,2,3,4,5,6};

String arrayToString = Arrays.deepToString(numbers);

Code Example 6

// Java program to demonstrate 
// working of Arrays.toString() 
  
import java.io.*; 
import java.util.*; 
  
class GFG { 
    public static void main(String[] args) 
    { 
  
        // Let us create different types of arrays and 
        // print their contents using Arrays.toString() 
        boolean[] boolArr 
            = new boolean[] { true, true, false, true }; 
        char[] charArr 
            = new char[] { 'g', 'e', 'e', 'k', 's' }; 
        double[] dblArr 
            = new double[] { 1, 2, 3, 4 }; 
        int[] intArr 
            = new int[] { 1, 2, 3, 4 }; 
        Object[] objArr 
            = new Object[] { 1, 2, 3, 4 }; 
  
        System.out.println( 
            "Boolean Array: "
            + Arrays.toString(boolArr)); 
        System.out.println( 
            "Character Array: "
            + Arrays.toString(charArr)); 
        System.out.println( 
            "Double Array: "
            + Arrays.toString(dblArr)); 
        System.out.println( 
            "Integer Array: "
            + Arrays.toString(intArr)); 
        System.out.println( 
            "Object Array: "
            + Arrays.toString(objArr)); 
    } 
}

Learn ReactJs, React Native from akashmittal.com