Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String convertArrayToString(String[] array) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < array.length; i++) {
            sb.append(array[i]);
            // Do not append comma at the end of last element
            if (i < array.length - 1) {
                sb.append("-");
            }
        }
        return sb.toString();
    }
}