ameen
0
Q:

array to string

var myArray = ['no','u'];
var myString = myArray.toString();
8
const arr = [1, 2, 'a', '1a'];
const str = arr.toString();
console.log(str); //> "1,2,a,1a"
5
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var x = fruits.toString();
4
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"
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)
1
char[] charArray = new char[] {'b','u','z','z'};

String answer = new String(charArray);
3
var array = [1,2,3]

for(var i = 0; i < array.length ; i++){
    console.log(array[i])
}
2
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);
   }
}
1

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"
1
<array>.join(<splitting character(s)>);
8
implode("|",$type);
0
int[] numbers = new int[]{1,2,3,4,5,6};

String arrayToString = Arrays.deepToString(numbers);
-1
// 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)); 
    } 
} 
0

New to Communities?

Join the community