- 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
Java example to return a string representation of the deep contents of the array
To return a string representation of the deep contents of the specified array −
Example
import java.util.Arrays; public class Demo { public static void main(String[] args) { Object[] ob = {"One","Two", "Three", "Four"}; System.out.println("Array elements..."); for (Object value : ob) { System.out.println("Value = " + value); } System.out.println("The string representation of array is:"); System.out.println(Arrays.deepToString(ob)); } }
Output
This will produce the following output −
Array elements... Value = One Value = Two Value = Three Value = Four The string representation of array is: [One, Two, Three, Four]
Example
Let us now see another example −
import java.util.Arrays; public class Demo { public static void main(String[] args) { int[][] arr = new int[3][3]; arr[0][0] = 10; arr[0][1] = 20; arr[0][2] = 30; arr[1][0] = 40; arr[1][1] = 50; arr[1][2] = 75; arr[2][0] = 100; arr[2][1] = 150; arr[2][2] = 200; System.out.println(Arrays.deepToString(arr)); } }
Output
This will produce the following output −
[[10, 20, 30], [40, 50, 75], [100, 150, 200]]
- Related Articles
- Return the user-readable string representation of a masked array in Numpy
- Return the string representation of a scalar dtype in Python
- Python Pandas - Format and return the string representation of the Period object
- How to read the contents of a webpage into a string in java?
- Java Program to Create String from Contents of a File
- String representation of Boolean in Java
- How do I create a Java string from the contents of a file?
- Get the String representation of the current File object in Java
- How to get the string representation of numbers using toString() in Java?
- How to return the dataless object representation of a Polygon using FabricJS?
- How do we create a string from the contents of a file in java?
- How to write contents of a file to byte array in Java?
- Return the pickle of the masked array as a string in NumPy
- Return the length of a string array element-wise in Python
- Python Pandas - Return the Timestamp representation of the Period object

Advertisements