Java Print Contents Of Int Array Code Example

Snippet 1

  import java.util.Arrays;

class Scratch{
    public static void main(String[] args){
        int[] arr = new int[3];
        System.out.println( Arrays.toString( arr ));
       //prints [0, 0, 0]
    }
} 

Snippet 2

  int[] intArray = new int[] {1, 2, 3, 4, 5};
System.out.println(intArray);     // prints something like '[[email protected]' 

Copyright © Code Fetcher 2020

 

 

Published

Leave a comment

Your email address will not be published. Required fields are marked *