I am having an Array, I want to write set of 6 (six) items into text files.
Array:-
[C, A2, A, E, B, D, F,A3,C1,D1,G1]
output:-
test1.txt:-[C, A2, A, E, B, D]
test2.txt:-[F,A3,C1,D1,G1]
Object ia[] = al.toArray();
for(int i=0; i<ia.length; i++)
{count=1;
for(j=0;j<=5;j++)
{
System.out.println("Set"+ ia[j]);
}
j=j;
// System.out.println( ia[i]);
}
You might be looking for
Arrays.copyOfRange().Code snap:
Will yield (as expected):
Of course you can generzalize this to invoke
copyOfRange()in a loop with variables as the arguments (and not hard coded as the simple code snap)