Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String print(int... array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        if (array != null && array.length > 0)
            for (int i = 0; i < array.length; i++)
                sb.append(array[i]).append(i == array.length - 1 ? "]" : ", ");
        else {
            if (array != null && array.length == 0)
                sb.append("empty");

            sb.append("]");
        }
        return sb.toString();
    }

    public static String print(long... array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        if (array != null && array.length > 0)
            for (int i = 0; i < array.length; i++)
                sb.append(array[i]).append(i == array.length - 1 ? "]" : ", ");
        else
            sb.append("]");
        return sb.toString();
    }

    public static <M extends Object> String print(M... array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        if (array != null && array.length > 0)
            for (int i = 0; i < array.length; i++)
                sb.append(array[i]).append(i == array.length - 1 ? "]" : ", ");
        else
            sb.append("]");
        return sb.toString();
    }
}