开发者

How can we get the objects in reverse order from list object?

in my List object(of generic type of pojo class objects) i am getting that list by calling service method, as per my requirement i have to place those object values in reverse order, for example

List<MyPojo> listData = serviceObj.getTableDate();//get开发者_如何学Gos the total content of table
if(listData.size()>0){
  int i=0;
  while(i>=listData.size()){
    listData.get(i).getPojoId();
    listData.get(i).getPojoName();
  }
}

Note: please dont tell to me use iterator or to use ListIterator, because i am showing the data in Grid(JQuery) some logic will fail while using iterator, the code what written was just sample of few lines only.


Would Collections.reverse(list) work?


Guava has Iterables.reverse(List), which returns a reversed view of the original list without modifying it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜