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 android.util.Log;
import java.util.Collection;
import java.util.Iterator;

public class Main {
    private static String toString(Object message) {
        if (message == null) {
            return "[null]";
        }
        if (message instanceof Throwable) {
            return Log.getStackTraceString((Throwable) message);
        }
        if (message instanceof Collection) {
            return toString((Collection) message);
        }
        return String.valueOf(message);
    }

    private static String toString(Collection message) {
        Iterator it = message.iterator();
        if (!it.hasNext())
            return "[]";

        StringBuilder sb = new StringBuilder();
        sb.append('[');
        for (;;) {
            Object e = it.next();
            sb.append(e);
            if (!it.hasNext())
                return sb.append(']').toString();
            sb.append(',').append('\n').append(' ');
        }
    }
}