我有一个代码:
for(int i=0;i<fList.size();i++){
String targets="";
String values="";
String sql="INSERT INTO "+tableName+"("+targets+") VALUES("+values+")";
Map<Column, String> attrs=fList.get(i).getAttributes();
for(int j=0;j<columns.size();j++){
if(columns.get(j).getName().equalsIgnoreCase("kadnum")){
targets=targets+"kadnum,";
System.out.println("targets:"+targets);
values=values+attrs.get(columns.get(j))+",";
System.out.println("values:"+values);
}
if(columns.get(j).getName().equalsIgnoreCase("support_num")){
targets=targets+"support_num";
values=values+attrs.get(columns.get(j))+",";
}
}
System.out.println("sql="+sql);
}
然后出去:
INSERT INTO parcels () VALUES()
但是如果你改变System.out.println("sql="+sql);
我 System.out.println("targets="+targets);
得到:targets=kadnum,
为什么字符串sql不改变?