code: @SuppressWarnings(
  	{ "unchecked", "rawtypes" })
  	public static <T> List<Collection<T>> toPages(Collection<T> collection, int pageSize)
  	{
  		if (collection == null || collection.isEmpty())
  			return null;
  
  		int collectionSize = collection.size();
  
  		if (pageSize <= 0 || collectionSize <= pageSize)
  			return (List<Collection<T>>) Collections.singletonList(collection);
  
  		int initialSize = collectionSize / pageSize;
  
  		ArrayList<Collection<T>> list = new ArrayList(initialSize);
  
  		ArrayList<Object> current = new ArrayList<Object>();
  		for (Object object : collection)
  		{
  			current.add(object);
  
  			if (current.size() >= pageSize)
  			{
  				current.trimToSize();
  
  				list.add((Collection<T>) current);
  				current = new ArrayList<Object>();
  			}
  		}
  
  		if (!current.isEmpty())
  			list.add((Collection<T>) current);
  
  		return (List<Collection<T>>) list;
  
  	}
docs: ------------------------------------------------