Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to print a java array using Arrays.toString

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 302
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: