我已经从两个数据库的表中存储了两个arraylist中的记录。现在我想比较这两个arraylists。如果没有匹配,则将table1中的记录插入table2。
答案 0 :(得分:0)
以下是一些可能对您有帮助的示例代码。
java.util.ArrayList al1 = [Your first array list retrieval method from first table];
java.util.ArrayList al2 = [Your second array list retrieval method from second table];
//Use iterator to go through each element of al1
java.util.Iterator iter1 = al1.iterator();
while(iter1.hasNext()){
//I assume strings are there in your array list
java.lang.String currentElement = iter1.next();
if (!al2.contains(currentElement)){
//Your code to insert into second table
}
}