Java : Comparing two ArrayLists, remove values, which are not matching -


i need :

i have object, containing values. of these values equal , differs. based on same values need 2 compare 2 arraylists of these objects. @ least have remove entries aren't stored in both lists.

i wrote function, compares fields in object :

public void comparetwovalues(certainobj1, certainobj2){     boolean returnstmt = true;     for(int : keystocheck){     if(!(jop1.returnvalueforkey(i).equals(jop2.returnvalueforkey(i)))){             returnstmt = false;         }     }     return returnstmt; } 

now have problem, how access , remove objects, function returns false ?

i tried sort them of comparable interface , remove values, got 'concurrentmodificationexception' (yeah, know : used the iterator-loop).

thanks !

arraylist has boolean retainall(collection another) retains elements in collection contained in specified collection. make work in situation create wrapper on original object equals method compares required fields , place wrappers in arraylist.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -