lets say im given a txt file with lines of strings, where i have to take the first 50 lines and print them in reverse order(to clarify: the line does not change, but the order changes...50th line becomes 1st, 49th becomes 2nd, etc...) and then again for the next 50 lines until all lines are reversed.
So far i have multiple for loops going through 50 lines at a time and reversing them. But is there a more efficient way to do this? i was thinking of stacks, however i dont know how to manipulate the elements in a stack over than pop() and push().
this is what i got so far
for(int x = 49; x>=0; x--){
System.out.println(s.get(x));
}
for(int x = 149; x>=100; x--){
System.out.println(s.get(x));
}
...
...