import java.util.StringJoiner; public class Test { public static void main(String[] args) { String[] fields = {"name","position","salary"}; String table = "employee"; String select = buildSelectSql(table,fields); System.out.println(select); System.out.println("Select name,position,salary from employee".equals(select) ? "测试成功":"测试失败"); } static String buildSelectSql(String table,String[] fields){ StringJoiner sj = new StringJoiner(",","Select "," from "+table); for(String f:fields){ sj.add(f); } return sj.toString(); } }
Sign in to make a reply
省体育馆到了