Java List Print prettyPrintList(List list)

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

Description

Takes a list of integers and returns a conveniently formatted string.

License

Open Source License

Parameter

Parameter Description
list the list of items to be pretty printed.

Return

String representation of the elements of said list

Declaration

public static String prettyPrintList(List<Integer> list) 

Method Source Code


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

import java.util.List;

public class Main {
    private static final String ITEM_DELIMITER = "-";

    /**/*from   ww  w.j  a  v a2  s. co m*/
     * Takes a list of integers and returns a conveniently formatted string. We
     * need this to create filenames with the elements of the lists in them.
     * 
     * @param list the list of items to be pretty printed.
     * @return String representation of the elements of said list
     */
    public static String prettyPrintList(List<Integer> list) {
        String result = "";

        for (int i = 0; i < list.size(); i++) {
            result += list.get(i).toString();

            if (i < list.size() - 1) {
                result += ITEM_DELIMITER;
            }
        }

        return result;
    }
}

Related

  1. prettyList(List list)
  2. prettyPrint(List userPermissions)
  3. prettyPrint(List rows)
  4. prettyPrintArgv(List argv)
  5. prettyPrintList(Collection objects, String separator)
  6. prettyPrintWarningMessage(final List results, final String message)
  7. prettyRoleOutput(List roles, final String delimiter)
  8. print(Collection> collections)
  9. print(int totalErrors, int totalTechnical, int totalSuccess, List filesWithErrorsList)