How can use two array lists in one for loop?
I have to enter some data to database, see my code. I am facing problem on two times execute Insert Query. So I want one for loop that contain both Strings and ArrayList.
public static ArrayList<String> ApplicationPackageList = new ArrayList<String>();
public static ArrayList<String> ApplicationLis开发者_如何转开发t = new ArrayList<String>();
.
.
.
for (String r : ApplicationPackageList ) {
DB.insertStmt.bindString(1, URLDecoder.decode(r));
DB.insertStmt.executeInsert();
}
for (String s : ApplicationList) {
// DB.insertStmt.bindString(1, URLDecoder.decode(r));
DB.insertStmt.bindString(2, URLDecoder.decode(s));
DB.insertStmt.executeInsert();
}
for(int i=0; i<ApplicationList.size() && i< ApplicationPackageList .size(); i++){
DB.insertStmt.bindString(1, URLDecoder.decode(ApplicationList.get(i)));
DB.insertStmt.bindString(2, URLDecoder.decode(ApplicationPackageList.get(i)));
DB.insertStmt.executeInsert();
}
List newList - new ArrayList();
newLIst.addAll(ApplicationList);
newLIst.addAll(ApplicationPackageList );
now iterate newList
, but it wouldn't make any positive impact on performance,
精彩评论