Frequent Question: How Do I Print an Array in Linux?

Frequent Question: How Do I Print an Array in Linux?
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:

  1. public class PrintArray {
  2. public static void main(String[] args) {
  3. //Initialize array.
  4. int [] arr = new int [] {1, 2, 3, 4, 5};
  5. System. out. println(“Elements of given array: “);
  6. //Loop through the array by incrementing value of i.
  7. for (int i = 0; i < arr. length; i++) {
  8. System. out. print(arr[i] + ” “);
Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.