Write a Java program for read and print array.


 

How to print array in Java

Java array is a data structure where we can store the elements of the same data type. The elements of an array are stored in a contiguous memory location. So, we can store a fixed set of elements in an array.

  1. import java.util.Arrays;  
  2. public class PrintArrayExample5  
  3. {  
  4. public static void main(String [] args)  
  5. {  
  6. //declaration and initialization of two dimensional array  
  7. String[] stringArray={"Hello","Java","Programmers"};  
  8. System.out.println(Arrays.asList(stringArray));  
  9. }  

Output:

[Hello, Java, Programmers]