Java Collection Create createAuthorString(Collection users)

Here you can find the source of createAuthorString(Collection users)

Description

create Author String

License

Open Source License

Declaration

public static String createAuthorString(Collection users) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static String createAuthorString(Collection users) {
        Collection<String> alreadySeen = new ArrayList<String>();
        String authorLabel = "";
        Iterator c = users.iterator();
        boolean firstAuthor = true;
        while (c.hasNext()) {
            String nextAuthor = (String) c.next();
            if (nextAuthor == null)
                continue;
            if (alreadySeen.add(nextAuthor)) {
                if (firstAuthor) {
                    authorLabel += " ";
                    firstAuthor = false;
                } else {
                    authorLabel += ", ";
                }//from  w ww.  j  av a 2 s  .  c o m
                authorLabel += nextAuthor;
            }
        }
        return authorLabel;
    }
}

Related

  1. create(Collection coll)
  2. createCollection( final Iterable object)
  3. createCollection(Collection col)
  4. createCollection(Object[] objects)
  5. createCollection(T... items)