tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Commons Lang3 > Arrays > Arrays to String

Arrays to String 

Apache Commons Lang 3.0 is a java library with lot of utilities and reusable components. This requires the library commons-lang3-3.0.1.jar to be in classpath. The following example shows using ArrayUtils.toString() API. It converts the array to string representation.

File Name  :  
com/bethecoder/tutorials/commons_lang/tests/arrays/ToStringTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.commons_lang.tests.arrays;

import org.apache.commons.lang3.ArrayUtils;

public class ToStringTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    String [] strings = "ONE""TWO""THREE""FOUR" };
    int [] ints = 123};
    
    System.out.println(ArrayUtils.toString(strings));
    System.out.println(ArrayUtils.toString(ints));
    System.out.println(ArrayUtils.toString(null));
    System.out.println(ArrayUtils.toString(new char [] {}));
  }

}
   

It gives the following output,
{ONE,TWO,THREE,FOUR}
{1,2,3,4}
{}
{}


                    Print

   



Books Recommendation

 
 
bl  br