- 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 does the method toString(obj[] a) do in java?
The toString(Object[] a) method of the java.util.Arrays class returns a string representation of the contents of the specified Object array. If the array contains other arrays of elements, they are converted to strings by the Object.toString() method inherited from Object, which describes their identities rather than their contents.
Example
import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { Object[] ob1 = new Object[] { 10, 20 }; System.out.println("The array is:"); for (Object number : ob1) { System.out.println("Number = " + number); } System.out.println("The string representation of array is:"); System.out.println(Arrays.toString(ob1)); } }
Output
The array is: Number = 10 Number = 20 The string representation of array is: [10, 20]
- Related Articles
- What does the method equals(obj[] a1, obj[] a2) do in java?
- What does the method hashCode(obj[] a) do in java?
- What does the method sort(obj[] a) do in java?
- What does the method remove(obj o) do in java?
- What does the method addElement(E obj) do in java?
- What does the method contains(obj o) do in java?
- What does the method indexOf(obj o) do in java?
- What does the method lastIndexOf(obj o) do in java?
- What is the purpose of toString() method? Or What does the toString() method do in java?
- What does the method set(int, obj o) do in java?
- What does the method toString(int[] a) do?
- What does the method sort(obj[] a, int fromIndex, int toIndex) do in java?
- What does the method fill(obj[], object val) do?
- What does the method fill(obj[], int fromIndex, int toIndex, int val) do in java?
- What does the method clear() do in java?

Advertisements