- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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]
- Related Articles
- what is the simplest way to print a java array
- The simplest way to get the user's current location on Android
- The simplest way to get the user's current location on Android using Kotlin?
- What's the best way to ensure a happy marriage?
- Java program to print Pascal's triangle
- What's the best way to detect a 'touch screen' device using JavaScript?
- Java Program to Print Star Pascal's Triangle
- What's the canonical way to check for type in python?
- What's the best way to trim std::string in C++?
- What's the Kotlin equivalent of Java's String[]?
- What is the simplest way to SSH using Python?
- What's the best way to open new browser window using JavaScript?
- What is the C# equivalent to Java's isInstance()?
- What is the Java equivalent to MySQL's smallint?
- What's the fastest way of checking if a point is inside a polygon in Python?

Advertisements