Java ArrayList Join join(ArrayList list)

Here you can find the source of join(ArrayList list)

Description

join

License

Mozilla Public License

Declaration

private static String join(ArrayList<String> list) 

Method Source Code

//package com.java2s;
/*/*from   w  ww .j  a  va  2  s.  c  om*/
 The contents of this file are subject to the Mozilla Public License Version 
 1.1 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at http://www.mozilla.org/MPL.
    
 The Original Code is the DoPE Pharmacoepidemiology Toolbox.
    
 The Initial Developer of the Original Code is the Brigham and Women's Hospital 
 Division of Pharmacoepidemiology.
    
 Contributor(s):
 Jeremy A. Rassen <jrassen@post.harvard.edu>
 */

import java.util.ArrayList;

public class Main {
    private static String join(ArrayList<String> list) {
        if ((list == null) || (list.size() == 0))
            return "";

        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (String item : list) {
            if (first)
                first = false;
            else
                sb.append(" ");
            sb.append(item.toUpperCase());
        }
        return sb.toString();
    }
}

Related

  1. join(ArrayList list, String delimeter)
  2. join(ArrayList arr, String separator)
  3. Join(ArrayList coll, String delimiter)
  4. join(ArrayList list, String delimiter)
  5. Join(ArrayList list, String delimiter)
  6. join(ArrayList list, String joinChar)
  7. join(ArrayList nameList, String delimiter)