java - Why after retainAll() the list comes to be null although it should has elements in it? -
now can list a, list b. , want new list a-(intersection of , b). when intersection, [].
list<map<string,string>> userdevices = clientdeviceservice.getuserdevice(userid); list<string> selecteddevices = new arraylist<string>(arrays.aslist(devices));//selecteddevices is------[stress0012,stress0014,] list<string> originaldevices = new arraylist<string>(); list<string> originaldevicesretain = new arraylist<string>();//copy operating for(map<string,string> originaldevid : userdevices){ originaldevices.add(originaldevid.get("devid")); } originaldevicesretain.addall(originaldevices); originaldevicesretain.retainall(selecteddevices); //originaldevicesretain [],and return false. originaldevices.removeall(originaldevicesretain); if(!originaldevices.isempty()){ }
why originaldevices [] has no elements in it?