Java List to String asStringList(Collection list)

Here you can find the source of asStringList(Collection list)

Description

Calls toString for each element and adds it to a new list.

License

Open Source License

Parameter

Parameter Description
list The list with elements.

Return

The list with strings.

Declaration

private static ArrayList<String> asStringList(Collection<?> list) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Fraunhofer Institute for Embedded Systems and
 * Communication Technologies ESK//from  w  ww .  j  a va 2 s . c o  m
 *
 * 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
 *
 * This file is part of ERNEST.
 *
 * Contributors:
 * Fraunhofer ESK - initial API and implementation
 *******************************************************************************/

import java.util.ArrayList;
import java.util.Collection;

public class Main {
    /**
     * Calls toString for each element and adds it to a new list.
     * 
     * @param list The list with elements.
     * @return The list with strings.
     */
    private static ArrayList<String> asStringList(Collection<?> list) {
        ArrayList<String> result = new ArrayList<String>(list.size());
        for (Object o : list) {
            result.add(o.toString());
        }
        return result;
    }
}

Related

  1. asString(List list)
  2. asString(List commandLine)
  3. asStringList( Collection objects)
  4. asStringList(Collection objects)
  5. asStringList(List coll)
  6. asStringList(Set attributes)
  7. convertListToStrArray(List list)