java android swap elements in List

Many times I want to swap the positions of the elements in the List. At this time, I can use the following code, which means to swap the positions of the index1 and index2 elements in the data

 

[java] view plain copy
  1. //data is List  
  2. Collections.swap(data,index1,index2); 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324982636&siteId=291194637