Java Collection Join joinSequence(Collection sequence)

Here you can find the source of joinSequence(Collection sequence)

Description

Joins the list of numbers as a dot-separated string.

License

Open Source License

Parameter

Parameter Description
sequence a parameter

Declaration

public static String joinSequence(Collection<Long> sequence) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 the CHISEL group and contributors. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 * /*from  w  w  w  .j ava 2  s  .  c  om*/
 * Contributors: the CHISEL group - initial API and implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    /**
     * Joins the list of numbers as a dot-separated string.
     * @param sequence
     * @return
     */
    public static String joinSequence(Collection<Long> sequence) {
        if (sequence == null) {
            return null;
        }
        StringBuilder builder = new StringBuilder();
        int i = 0;
        for (long l : sequence) {
            builder.append(l);
            i++;
            if (i < sequence.size()) {
                builder.append('.');
            }
        }
        return builder.toString();
    }
}

Related

  1. joinEmptyItemIncluded(Collection stringCollection, String delimiter)
  2. joinList(@SuppressWarnings("rawtypes") Collection c)
  3. joinNullSafe(Collection collection, String separator)
  4. joinObjects(Collection objects)
  5. joinQuoted(Collection col)
  6. joinSort(Collection c, String separator)
  7. joinSorted(Collection s, String delimiter)
  8. joinString(Collection values, String delimiter)
  9. joinStringCollection(Collection collection, String separator)

  10. HOME | Copyright © www.java2s.com 2016