Convert array To String - Java java.lang

Java examples for java.lang:String Array

Description

Convert array To String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String[] stringArray = new String[] { "1", "abc", "level", null,
                "java2s.com", "asdf 123" };
        String string = "java2s.com";
        System.out.println(arrayToString(stringArray, string));
    }//from w  w  w.j a  v  a  2 s.c om

    public static String arrayToString(String[] stringArray, String string) {
        StringBuilder builder = new StringBuilder();

        for (String str : stringArray) {
            builder.append(str + string);
        }
        return builder.toString();
    }
}

Related Tutorials