how to turn a string in to a array code example

Example 1: 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"

Example 2: how to convert string into string array

public static void main(String[] args) {
    String str = "abcdef";

    String [] array = str.split(""); //   {"a", "b", "c", "d", "e", "f" }.
    
}