• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dividing a List into chunks

 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having trouble dividing a List of Objects into several chunks. I have an ArrayList of unknown(variable) no. of objects and I want to split them into groups of 300. So suppose I receive a List of 1000 objects I need a method that will return a List of Lists (List of 4 Lists containing 300, 300, 300, & 100 objects respectively)

public List<List> split(List bigChunk)
{

}

Does anybody have an idea?
 
Paul Clapham
Sheriff
Pie
Posts: 20739
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with the subList() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic