for(int i =0; i < size; i++) { List<String> s = sourceList.subList(s,t); } 

I want to create s + i files in this place List s (s1, s2, etc.).

  • And the question is what? How to create an array of lists? - pavel
  • no, the question is how to name s to sign the number i. s + i does not work - Stas
  • In this formulation, the answer is no way. But you need it. - pavel
  • and if I need to create several sheets ... but how many determines the size parameter ... how can I solve this problem? - Stas
  • one
    I kind of wrote immediately, an array of sheets. ArrayList <List <String >> - pavel

1 answer 1

In java, as in almost all languages ​​with static typing, this is not possible. But you do not need the variables s1, s2, s3 ... You can create an array of variables of any type (even an array type). In Java, this might look like this: ArrayList<List<String>> s = new ArrayList<>(); further s.add(sourceList.subList(i*10,(i+1)*10)) Took the constant from your previous question.