|
Arrays to String
The following example shows how to convert any given array to string using Arrays.toString() API.
|
package com.bethecoder.tutorials.utils.arrays;
import java.util.Arrays;
public class Arrays2String {
public static void main (String [] args) {
String [] strArray = null;
System.out.println(Arrays.toString(strArray));
strArray = new String [] {};
System.out.println(Arrays.toString(strArray));
strArray = new String [] { "one", "two", "three", "four"};
System.out.println(Arrays.toString(strArray));
int [] intArray = { 7, 8, 6};
System.out.println(Arrays.toString(intArray));
}
}
|
| |
It gives the following output,
null
[]
[one, two, three, four]
[7, 8, 6]
|
|