Question is simple:
I have two List
List columnsOld = DBUtils.GetColumns(db, TableName);
List columnsNew = DBUtils.GetCol
Since retainAll won't touch the argument collection, this would be faster:
List columnsOld = DBUtils.GetColumns(db, TableName);
List columnsNew = DBUtils.GetColumns(db, TableName);
for(int i = columnsNew.size() - 1; i > -1; --i){
String str = columnsNew.get(i);
if(!columnsOld.remove(str))
columnsNew.remove(str);
}
The intersection will be the values left in columnsNew. Removing already compared values fom columnsOld will reduce the number of comparisons needed.