Discuss / Java / ✔

呆萌阿腾

#1 Created at ... [Delete] [Delete and Lock User]
    static String buildSelectSql(String table, String[] fields) {
        StringJoiner sj = new StringJoiner(", ", "SELECT ", " FROM " + table);
        for (String field : fields) {
            sj.add(field);
        }
        return sj.toString();
    }

呆萌阿腾

#2 Created at ... [Delete] [Delete and Lock User]
    static String buildSelectSql(String table, String[] fields) {
        return "SELECT " +  String.join(", ", fields) + " FROM " + table;
    }

  • 1

Reply