Simplest Method to Print Array in Java Last Updated : 02 Dec, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 to print the elements // using Arrays.toString() Method import java.util.Arrays; public class GFG { public static void main(String[] args) { // integer array int[] a = { 1, 2, 3, 4, 5 }; // string array String[] s = { "vivek", "deeksha", "ankur" }; // Printing integer array using toString() Method System.out.println(Arrays.toString(a)); // Printing string array using toString() Method System.out.println(Arrays.toString(s)); } } Output[1, 2, 3, 4, 5] [vivek, deeksha, ankur] For more methods, please refer to the article - Java Program to Print the Elements of an Array Comment More infoAdvertise with us Next Article Simplest Method to Print Array in Java V vivekchaudharyy Follow Improve Article Tags : Java Java Programs Java-Arrays Java Examples Practice Tags : Java Similar Reads 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 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 How to Print an Array in Java Without using Loop? 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.lengt 2 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 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 Like