How _NOT_ to Reverse a List

While fixing a bug in our code base I came across this interesting piece of code for reversing a list. I thought I should share this work of art with others as well.

Oh forgot to say “Please don’t try this in your code base.

//List of added beans
ArrayList<SomeBean> list1 = manager.getAllValueBeans(true,idsArray, da);

ArrayList<SomeBean> list2 = manager.getAllValueBeans(true,idsArray, da);


// Final list reversal
ArrayList<SomeBean> list = new ArrayList<SomeBean>();

if(dbList!=null) {

for (int i=dbList.size()-1; i>-1; i--) {



Every single line of this code is a piece of art

How _NOT_ to Reverse a List

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s