Java List Print printList(List list)

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

Description

print List

License

Open Source License

Declaration

public static <T> void printList(List<T> list) 

Method Source Code

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

import java.util.List;

public class Main {
    public static <T> void printList(List<T> list) {
        if (list == null) {
            System.out.println("NULL");
            return;
        }/* w  ww.j  a  v a  2s  .  c o  m*/

        if (list.size() == 0) {
            System.out.println("[]");
            return;
        }

        printNonEmptyList(list);
    }

    private static <T> void printNonEmptyList(List<T> list) {
        int len = list.size();
        System.out.print("[");
        for (int i = 0; i < len; i++) {
            if (i == len - 1) {
                System.out.println(list.get(i) + "]");
            } else {
                System.out.print(list.get(i) + ", ");
            }
        }
    }
}

Related

  1. printList(List list0)
  2. printList(List list, String filename)
  3. printList(List list)
  4. printList(List> list)
  5. printList(List truthTableHeader)
  6. printList(List list)
  7. printListPair(List list)
  8. printListStrings(List list, String listDescription)
  9. printListV(List l)