xxxxxxxxxx
// Applicable for Arrays only. not for ArrayList.
String myStr = Arrays.toString(arr);
xxxxxxxxxx
// convert an array to string javascript
// using reduce()
let array = ['A', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'];
let output = array.reduce((a, b) => a + ' ' + b);
console.log(output); //A quick brown fox jumps over the lazy dog
// using join()
let output1 = array.join(" ");
console.log(output1); //A quick brown fox jumps over the lazy dog
xxxxxxxxxx
print_r($request->education); //It is an array print
$str_json = json_encode($request->education); //array to json string conversion
echo $str_json; // printing json string
print_r(json_decode($str_json)); //printing array after convert json string to array
exit; // exiting further execution to check resutls
xxxxxxxxxx
Arrays.toString(charArr);
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);
}
}
xxxxxxxxxx
char[] charArray = new char[] {'b','u','z','z'};
String answer = new String(charArray);
xxxxxxxxxx
const array = [1, 2, 3, 4, 5];
const string1 = array.join(); // Convert array to comma-separated string
console.log(string1); // Output: "1,2,3,4,5"
const string2 = array.toString(); // Another way to convert array to comma-separated string
console.log(string2); // Output: "1,2,3,4,5"
const string3 = JSON.stringify(array); // Convert array to JSON string
console.log(string3); // Output: "[1,2,3,4,5]"
xxxxxxxxxx
char[] charArray = new char[] {'b','u','z','z'};
Stream<String> stream = Arrays.stream(charArray);
String store=stream.collect(Collectors.joining(" "));
System.out.println(store);