Java ArrayList Print printListFlat(ArrayList list)

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

Description

print List Flat

License

Open Source License

Parameter

Parameter Description
list a parameter

Declaration

public static void printListFlat(ArrayList<String> list) 

Method Source Code


//package com.java2s;

import java.util.ArrayList;

public class Main {
    /**//  w w w  . j  a v a 2s  .com
     * @param list
     */
    public static void printListFlat(ArrayList<String> list) {
        if (list == null || list.isEmpty()) {
            System.out.println("\tNO ITEM !!");
            return;
        }

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < list.size(); i++) {
            if (i == 0)
                sb.append("{");

            sb.append(list.get(i));

            if (i != list.size() - 1)
                sb.append(",");
            if (i == list.size() - 1)
                sb.append("}");
        }
        System.out.println(sb.toString());
    }
}

Related

  1. printArrayList(ArrayList list)
  2. printArrayList(ArrayList _array)
  3. printArrayListInt(ArrayList list)
  4. printComboBoxView(ArrayList alOptionValue, String sDefaultValue)
  5. printEdgeCycleMembership(final int[][] cyclesData, final ArrayList[] nodeCycleMembership)
  6. printMatrix(ArrayList> grid)
  7. printReport(ArrayList words, ArrayList searched)
  8. printStringArrayList(ArrayList list)
  9. writeArrayList(ArrayList objects, String separator, String final_conjunction, String prefix, String suffix)