java - Swapping items in list using only add and remove -


i wondering if work swap around items in list. example: initial items: m l -> desired: l m

for (int = 1 ; < testlist.size() ; i++ )      testlist.add( 0 , testlist.remove (i)); 

your idiom works*, collections.reverse(testlist); optimized way it.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

c# - Abstract method in public abstract class implementing an internal interface doesn't compile? -

authentication - Mongodb revoke acccess to connect test database -