java - How to compare List of Long and return the number of matches -


i have 2 list<long> id = [2316, 2317, 2318] ,

list<long> existingid = [1004, 1762, 1892, 1342, 1942, 2316] 

i want programmatically in java know how many did not match , numbers, in case 2 , 2317,2318

programmatically, tried following, went infinite loop false always:

for(int i=0; i<webcrtidlistexisting.size(); i++){     system.out.println("#########" + webcrtidlistexisting.contains(webcrtidlistnightly)); } 

you can try this:

     collection<integer> id = arrays.aslist(2316, 2317, 2318);      collection<integer> existingid = arrays.aslist(1004, 1762, 1892, 1342, 1942, 2316);      collection<integer> similar = new hashset<integer>( id );     similar.removeall( existingid );     system.out.println("different:"+similar);     system.out.println("#of items differnt:"+similar.size()); 

Comments