How to Print an Array in Java Without using Loop? Last Updated : 01 May, 2022 Comments Improve Suggest changes Like Article 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. Java // Java program to get the String // representation of an array and print it import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // Get the array int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // Get the String representation of array String stringArr = Arrays.toString(arr); // print the String representation System.out.println("Array: " + stringArr); } } 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. Java // Java program to print an array // without creating its String representation import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // Get the array int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // Print the array System.out.println("Array: " + Arrays.toString(arr)); } } Output: Array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Comment More infoAdvertise with us Next Article How to Print an Array in Java Without using Loop? C code_r Follow Improve Article Tags : Java Java Programs Java-Array-Programs Practice Tags : Java Similar Reads How to Print List Items Without Brackets in Java? In Java, if you want to print the elements of a list without brackets [ ]. you need to manually iterate through the list and print each element separately. The brackets are automatically added when you directly print the entire list. In this article, we will discuss how to print list items without b 2 min read How to Declare an ArrayList with Values in Java? ArrayList is simply known as a resizable array. Declaring an ArrayList with values is a basic task that involves the initialization of a list with specific elements. It is said to be dynamic as the size of it can be changed. Proceeding with the declaration of ArrayList, we have to be aware of the co 2 min read Java Program to Print the Elements of an Array An array is a data structure that stores a collection of like-typed variables in contiguous memory allocation. Once created, the size of an array in Java cannot be changed. It's important to note that arrays in Java function differently than they do in C/C++As you see, the array of size 9 holds elem 6 min read Simplest Method to Print Array in Java Arrays.toString() Method of java.util.Arrays class is the simplest method to print an array in Java. This method takes an array as a parameter and returns a string representation of the array and it can work with all types of arrays like integer arrays, string arrays, etc.Example:Java// Java Program 1 min read Java Program to Iterate Over Arrays Using for and for-each Loop In Java, arrays are a collection of elements of the same type. To access and manipulate elements, we can use iteration techniques such as the for loop and for-each loop (also known as the enhanced for loop).Program to Iterate Over Arrays Using for and for-each Loop in JavaIn the below example, we wi 1 min read Java Program to Convert an Array into a List In Java, arrays and lists are two commonly used data structures. While arrays have a fixed size and are simple to use, lists are dynamic and provide more flexibility. There are times when you may need to convert an array into a list, for instance, when you want to perform operations like adding or r 4 min read Java Program to Print the Smallest Element in an Array Java provides a data structure, the array, which stores the collection of data of the same type. It is a fixed-size sequential collection of elements of the same type. Example: arr1[] = {2 , -1 , 9 , 10} output : -1 arr2[] = {0, -10, -13, 5} output : -13 We need to find and print the smallest value 3 min read Print a 2D Array or Matrix in Java In this article, we will learn to Print 2 Dimensional Matrix. 2D-Matrix or Array is a combination of Multiple 1 Dimensional Arrays. In this article we cover different methods to print 2D Array. When we print each element of the 2D array we have to iterate each element so the minimum time complexity 4 min read Java Program to Print the kth Element in the Array We need to print the element at the kth position in the given array. So we start the program by taking input from the user about the size of an array and then all the elements of that array. Now by entering the position k at which you want to print the element from the array, the program will print 2 min read Convert a String to Character Array in Java Converting a string to a character array is a common operation in Java. We convert string to char array in Java mostly for string manipulation, iteration, or other processing of characters. In this article, we will learn various ways to convert a string into a character array in Java with examples.E 2 min read Like