Share on Google+Share on Google+

Convert Array to String

In this section, you will learn how to convert array to string.

Convert Array to String


In this program we have taken an array of type String as "String stringarray[] = {"chandan", " " ,"tamana", " " ,"suman", " " ,"Ravi"};" and to convert it to String we have used "arrayToString(stringarray));" as shown below. Therefore we get the following output.

Here is the code of this program:

import java.util.*;
import java.util.Arrays;
import java.lang.String;

public class arraytosting {
  public static void main(String[] args) {
  arraytosting arstr = new arraytosting();

  public arraytosting(){
  String stringarray[] 
"chandan"" " ,"tamana"" " ,"suman"" " ,"Ravi"};
  System.out.println("Array Value = " 
+ arrayToString

  public String arrayToString(String[] stringarray){
  String str = " ";
  for (int i = 0; i < stringarray.length; i++) {
  str = str + stringarray[i];
  return str;

Output of the program:


C:\unique>java arraytosting
Array Value = chandan tamana suman Ravi


Download this example.


Posted on: August 9, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Convert Array to String   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image