Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    /**
     * buildStringFromArray
     *
     * @param stringArray the String[] to convert
     * @param separator   the string separator
     * @return the separated string
     */
    public static String buildStringFromArray(ArrayList<String> stringArray, String separator) {
        if (stringArray.size() > 0) {
            StringBuilder nameBuilder = new StringBuilder();
            for (String n : stringArray) {
                nameBuilder.append(n).append(separator);
            }
            nameBuilder.deleteCharAt(nameBuilder.length() - 1);
            return nameBuilder.toString();
        } else {
            return null;
        }
    }
}