Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Iterator;

public class Main {
    public static <E> String toString(Iterator<E> iterator) {
        if (iterator == null || !iterator.hasNext()) {
            return "[]";
        }
        StringBuilder builder = new StringBuilder();
        builder.append('[');
        while (iterator.hasNext()) {
            builder.append(iterator.next()).append(',').append(' ');
        }
        return builder.append(']').toString();
    }
}