Open In App

How to Print an Array in Java Without using Loop?

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
9 Likes
Like
Report

Given an array arr in Java, the task is to print the contents of this array without using any loop. First let's see the loop method. 
Loop method: The first thing that comes to mind is to write a for loop from i = 0 to n, and print each element by arr[i].
Pseudo Code:

for(int i = 0; i < Array.length; i++)
        System.out.println(Array[i]);

Concept: We will be using the toString() method of the Arrays class in the util package of Java. This method helps us to get the String representation of the array. This string can be easily printed with the help of the print() or println() method.
Example 1: This example demonstrates how to get the String representation of an array and print this String representation.


Output: 
Array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

 

Example 2: This array can also be printed directly without creating a string.


Output: 
Array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

 

Practice Tags :

Similar Reads