Java tutorial
//package com.java2s; import java.util.List; public class Main { public static <T> String listToSqlString(List<T> list) { StringBuilder builder = new StringBuilder(); boolean firstCheck = true; for (T s : list) { if (firstCheck) { builder.append("'" + s + "'"); firstCheck = false; } else { builder.append(","); builder.append("'" + s + "'"); } } return builder.toString(); } }