public static <T>List<T> subList(List<T> list,int start,int max){
  if (list == null) {
    return null;
  }
  int end=start + max;
  return list.subList(Math.max(0,start),Math.min(list.size(),end));
}

public static < T > List < T > subList ( List < T > list , int start , int max ) { if ( list == null ) { return null ; } int end = start + max ; return list . subList ( Math . max ( 0 , start ) , Math . min ( list . size ( ) , end ) ) ; }
returns the sub list of the given list avoiding exceptions , starting on the given start index and returning at maximum the given max number of items .
