开发者

How can use two array lists in one for loop?

开发者 https://www.devze.com 2023-02-14 06:10 出处:网络
I have to enter some data to database, see my code. I am facing problem on two times execute Insert Query.

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,

0

精彩评论

暂无评论...
验证码 换一张
取 消