Here you can find the source of printNonEmptyList(List
private static <T> void printNonEmptyList(List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { 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) + ", "); }//from w ww .j a va 2 s . c o m } } }