When the number of data items is determined, the backend only needs to return two items, and then it can be traversed directly. There is no need to make it so complicated...
What does it mean that your question is difficult to understand? ! ! Do you mean something like “display in pages”? And dynamically return data based on the number of lists? If this is the case, then you can use ArrayList and use the sort method of ArrayLiast to sort. After sorting, you can pick whichever item you want without any confusion.
Using
Java8
only requires one line of codeArrayList
的get(index)
Don’t worry about the efficiency of the method. Your problem description and title seem unrelated. Can you understand it?When the number of data items is determined, the backend only needs to return two items, and then it can be traversed directly. There is no need to make it so complicated...
What does it mean that your question is difficult to understand? ! !
Do you mean something like “display in pages”? And dynamically return data based on the number of lists?
If this is the case, then you can use ArrayList and use the sort method of ArrayLiast to sort. After sorting, you can pick whichever item you want without any confusion.