
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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(int a) Do?
The toString(int[]) method of the class java.util.Arrays return a string representation of the contents of the specified int array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).
Example
import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { int[] i1 = new int[] { 33, 12, 98 }; System.out.println("The array is:"); for (int number : i1) { System.out.println("Number = " + number); } System.out.println("The string representation of array is:"); System.out.println(Arrays.toString(i1)); } }
Output
The array is: Number = 33 Number = 12 Number = 98 The string representation of array is: [33, 12, 98]
Advertisements