title: Custom pagination by array list
body: <p>I want to create, in java code, a custom pagination by an array list</p>
  
  <pre><code>import org.springframework.data.domain.Sort;
  import org.springframework.data.domain.PageRequest;
  import org.springframework.data.domain.Page;
  import org.springframework.data.domain.PageImpl;
  import org.springframework.data.domain.Sort.Direction;
  ...    
  
      int page = 0;
      int count = 8;
      String sortOrder = "desc";
      String sortBy = "id";
  
      Sort sort = new Sort(Direction.fromString(sortOrder), sortBy);
      PageRequest pageable = new PageRequest(page, count, sort);
  
      List&lt;Impianto&gt; impiantos = myService.findMyMethod(); // returned 30 objects 
      Page&lt;Impianto&gt; pageImpianto = new PageImpl&lt;Impianto&gt;(impiantos, pageable, impiantos.size()); 
  </code></pre>
  
  <p>The script above doesn't return a page of 8 elements. Why?</p>
  
  <p>N.B. the list didn't return from db</p>
  
  <p>Can you help me?</p>