public static <T>List<T> last(List<T> elements,int limit){
  ArrayList<T> res=new ArrayList<T>();
  for (int i=0; i < elements.size(); i++) {
    if (res.size() >= limit) {
      break;
    }
    res.add(elements.get(elements.size() - 1 - i));
  }
  return res;
}

public static < T > List < T > last ( List < T > elements , int limit ) { ArrayList < T > res = new ArrayList < T > ( ) ; for ( int i = 0 ; i < elements . size ( ) ; i ++ ) { if ( res . size ( ) >= limit ) { break ; } res . add ( elements . get ( elements . size ( ) - 1 - i ) ) ; } return res ; }
getting last elements of list in reverse order
