public class StringLearn1 { public static void main(String[] args){ //请使用StringBuilder构造一个INSERT语句: String[] fields = { "name", "position", "salary" }; String table = "employee"; String insert = buildInsertSql(table, fields); System.out.println(insert); String s = "INSERT INTO employee (name, position, salary) VALUES (?, ?, ?)"; System.out.println(s.equals(insert) ? "测试成功" : "测试失败"); } static String buildInsertSql(String table,String[] fields){ String Scentens = "INSERT INTO %s (%s) VALUES (?, ?, ?)"; return String.format(Scentens, table, String.join(", ", fields)); }}
Sign in to make a reply
iruto-omotteta