How Can We Print an Array in Java ?

We can print an array by using methods of Arrays class. We can either use Arrays.toString() method or we can use Arrays.deepToString() method.

Since array doesn't implement toString() method by itself, just passing an array to System.out.println() will not print its contents. But we can use Arrays.toString() to print each element of an array.



You May Interest

When is UnsupportedOperationException Thrown in Java ?

How Will You Implement ApplicationContext in Spring Framework ?

What is the Different Type of Tag Library Groups in JSTL ?

Why Does Java Provide Default Constructor ?

What is the Difference Between wait and sleep Methods in Java ?