An Array is a collection of data of similar data type.
We can use Arrays.toString(array_name) to print a java array.
Arrays.toString() return a String for a given set of elements specified in brackets([]) and,
the elements are separated with comma(,).
import java.util.Arrays;
public static void main(String[] args) {
int[] integerArray = new int[] {1, 2, 3, 4, 5};
String[] stringArray = new String[] {"XYZ", "ABC"};
System.out.println(Arrays.toString(integerArray));
System.out.println(Arrays.toString(stringArray));
}
0 Comment(s)