开发者

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

开发者 https://www.devze.com 2023-02-06 07:03 出处:网络
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

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

精彩评论

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