Array class toString(short[] a)method example
Array class toString(short[] a)method example. This example shows you how to use toString(short[] a) method.This method Returns a string representation of the contents of the specified array.
Here is the code:-
/**
* @Program that Returns a string representation of the contents of the
* specified array.
* toString8Array.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class toString8Array {
public static void main(String[] args) {
//Creating a short array
short b[]={1,2,3,4,5,6,7,6,5,4};
// Returns a string representation of the contents of the specified array.
String s=Arrays.toString(b);
//Displays the array
System.out.print("The array of bytes into ascending order is:-");
for(int i=0;i<b.length;i++)
System.out.print("\t"+b[i]);
}
} |
Output of the program:-
| The array of bytes into ascending order is:- 1 2 3 4 5 6 7 6 5 |
|