get Array As String - Java java.lang

Java examples for java.lang:String Array

Description

get Array As String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        Object[] array = new String[] { "1", "abc", "level", null,
                "java2s.com", "asdf 123" };
        System.out.println(getArrayAsString(array));
    }//from   w ww.j ava 2  s.  co  m

    public static String getArrayAsString(Object[] array) {
        String result = "";
        if (array != null) {
            for (Object object : array) {
                result += object.toString() + ", ";
            }
        }
        return result;
    }
}

Related Tutorials