tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > Core > Arrays > Arrays to String

Arrays to String 

The following example shows how to convert any given array to string using Arrays.toString() API.

File Name  :  
com/bethecoder/tutorials/utils/arrays/Arrays2String.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.utils.arrays;

import java.util.Arrays;

public class Arrays2String {

  public static void main (String [] args) {
    
    String [] strArray = null;
    System.out.println(Arrays.toString(strArray));
    
    strArray = new String [] {};
    System.out.println(Arrays.toString(strArray));
    
    strArray = new String [] { "one""two""three""four"};
    System.out.println(Arrays.toString(strArray));
    
    int [] intArray = 786};
    System.out.println(Arrays.toString(intArray));
  }
}
   

It gives the following output,
null
[]
[one, two, three, four]
[7, 8, 6]



 
  


  
bl  br