Java List to String toString(List list)

Here you can find the source of toString(List list)

Description

Forms the StringList into a normal sentence with Spaces

License

Open Source License

Parameter

Parameter Description
list The List you want to convert

Return

Converted String

Declaration

public static String toString(List<String> list) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**/*from   w  w w .  j  ava 2s  .  c o m*/
     * Forms the StringList into a normal sentence with Spaces
     *
     * @param  list The List you want to convert
     * @return      Converted String
     */
    public static String toString(List<String> list) {
        return toString(list.toArray(new String[list.size()]));
    }

    /**
     * Forms the String Array into a normal sentence with Spaces
     *
     * @param  list The List you want to convert
     * @return      Converted String
     */
    public static String toString(String... list) {
        return toString(0, list);
    }

    /**
     * Forms the String Array into a normal sentence with Spaces
     * and excludes the first X entries
     *
     * @param  list The List you want to convert
     * @param  excluded The Start Index for the String Array
     * @return      Converted String
     */
    public static String toString(int excluded, String... list) {
        StringBuilder builder = new StringBuilder();

        for (int i = excluded; i < list.length; i++) {
            if (i > excluded)
                builder.append(" ");
            builder.append(list[i]);
        }

        return builder.toString();
    }
}

Related

  1. toString(List list)
  2. toString(List> classes)
  3. toString(List> values)
  4. toString(List listOriginal)
  5. toString(List input, String sep)
  6. toString(List list)
  7. toString(List list, String delimiter)
  8. toString(List list, String split)
  9. toString(List strings)

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