Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What's the simplest way to print a Java array?
Generally, to print the contents of an array you need to use for loops, in addition to that you can directly print an array using the toString() method of this class. This method accepts an array as a parameter and returns it in String format.
Example
import java.util.Arrays;
public class PrintingArrays {
public static void main(String args[]) {
int[] myArray = {23, 93, 30, 56, 92, 39};
System.out.println(Arrays.toString(myArray));
}
}
Output
[23, 93, 30, 56, 92, 39]
Advertisements
