Contents
How do you print an array in Unix?
To write all elements of the array use the symbol “@” or “*”. The difference between “[email protected]” and “$*” is “[email protected]” expand each element as a separate argument, however “$*” expand to the arguments merged into one argument.
How do I print an array element?
Program:
- public class PrintArray {
- public static void main(String[] args) {
- //Initialize array.
- int [] arr = new int [] {1, 2, 3, 4, 5};
- System. out. println(“Elements of given array: “);
- //Loop through the array by incrementing value of i.
- for (int i = 0; i < arr. length; i++) {
- System. out. print(arr[i] + ” “);